Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How does UV Map data work? And will this idea work?

Author
Message
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Jan 2012 02:18
I've had an idea, but I don't know if it's possible, because I don't know how UV map data relates to a 3D object.

UV mapping a sphere is difficult. So I had this idea. To fill a sphere with tiny coloured sphere with the large sphere you have a transparent alpha texture. Now you can see the tiny sphere inside the large sphere. You set the tiny sphere to a distance routine from the centre of the large sphere. Now you can spin the tiny sphere around inside the large sphere to create something like Jupiter's storms.

The next step is to take the colour of each tiny sphere, and compare it's location to the UV map data location. This is the part that I don't understand. How does 3D location relate to UV map location? Then to put the colour into that UV map location.

It sounds possible so long as the 3D coordinates can be translated into UV map coordinates.

Some of you have worked on UV mapping on the fly. I think that some of you know how to take a colour from a 3D location, and put it on the sphere. This, in theory should give you a perfect sphere texture, so long as you handle the small sphere locations really well.

I want to do this on the fly, because my project is to use many sphere inside large sphere, and I need to reduce the number of sphere inside my objects. So to create an animated texture on the fly would be ace.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 9th Jan 2012 12:22 Edited at: 9th Jan 2012 12:25
I'm not the greatest mathematician, and I am not 100% sure about what you are trying to achieve but I know a thing or two about UV maps.

Each vertex in the sphere contains a UV coordinate, so you can compare each vertex position to the position of the inner spheres; and add this in ratio (0.0 to 1.0) in UV coordinates to find the approximate location you need. With shere based UV mapping, from 0 - 360 degrees along the circumference, you count from 0.0 to 1.0 along the texture. A UV editor would be a great visual aid. Your effect just requires mathemtical work to create the effect you want. The UV coordinates can be obtained from vertex data or memblock mesh data.

Usually, shaders are best for special effects; you could pass the calculated coordinate into a HLSL vector constant in a shader which could adjust the vertex tones in a vertex shader; or you could pass the screen location of the inner sphere to draw pixels in a pixel shader.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Jan 2012 16:26
Ok thanks! So it's possible to do it. That's what I wanted to know.

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jan 2012 16:44
A while ago I made a skysphere generator. What that did, is point at every pixel in the sphere map, say a 1024x1024 pixel, means that on the X coordinate you have the Y angle, and on the Y coordinate, you have the X angle. So I just rotate the camera, grab the centre pixel, apply that to the sphere map for that location and angle, and it captures a sphere map from any 3D scene in DBPro. Handy for grabbing a skysphere that exactly matches the lighting and terrain and everything in the game.

Spheres often have badly warped poles, because it is difficult to effectively UV map the poles, especially when they meet at a single vertex. But what I have considered is, why not use 2 seperate skyspheres. The poles would be removed, then a second skysphere added, and rotated 90 degrees - so instead of a pole with nasty UV mapping, you have a rotated sphere, and textures that match much better. It is possible to get those results from a skycube, but that's 6 textures, and not an ideal drawing situation. The camera range is a radius, so a skyphere allows more conservative culling than a skycube - probably render about 30% more when using a skycube I'd say.

Anyway, the last thing I've done with this idea, is to make a planet generator, which I think might be close to what you are talking about. Imagine taking a sphere, and filling it with different sized spheres. At any vertex in your original sphere, you could calculate the closeness of those filling spheres, work out a 'strength', and apply that to the height of that vertex in accordance with the planet (so it moves along it's normal, out from the centre of the sphere. It's possible to generate a pretty decent planet with that technique, even generate a texture to go with it - you still have the problem with poles, but that is often a minor problem with planets (which have poles anyway, might as well use them). That principle could be applied to colour too of course.

The main thing is to calculate the texture pixel, or vertex height, or whatever based on 3D - a standard sphere might not look it's best, but a geosphere might cope better, or indeed the rotated sphere and double texture idea. Unfortunately there is not ideal way to wrap a sphere without breaking it up (maybe into segments like an orange) - not without some detail suffering somewhere.

Health, Ammo, and bacon and eggs!
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Jan 2012 17:10 Edited at: 9th Jan 2012 17:11
Well combined with that, you also have the ability to create the swirly weather conditions inside the large sphere. You just spin the mini sphere around, and slow some down. The slow ones will create swirly patterns as the other sphere go around them.

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jan 2012 17:55
Yeah, it could even loop all the movements, so a set of weather texture images could be created and applied one by one.
One neat thing about molding a planet like that, is you could use different shapes of planet, different polygon counts, then just go through every vertex and offset that. So, mimicking how Spore generates it's planets - it uses 6 sides, so if you had a segmented cube (like a rubics cube with much more than 9 segments per side), it would mold to the planet shape, and also allow for more accurate texturing... instead of 2 poles, you'd have 8 poles, but the interference would be practically un-noticable because the 6 textures would meet up perfectly, and the normals would be fairly easy to calculate too.

Add in a sphere for water with a generated texture and it could be a pretty sweet looking planet.

Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2026-07-09 21:18:46
Your offset time is: 2026-07-09 21:18:46