Sign in to follow this  
Aken H Bosch

Question about spheres and maybe sphere maps

Recommended Posts

Aken H Bosch    348
I want to render in realtime a relatively smooth 3d sphere with a texture that is generated at either program load or game start. I am making a game (RTS) where gameplay is confined to the surface of a sphere. Instead of having the option of using a cube map and rendering that before-hand, I now will have to generate a texture and then map that onto the sphere where the action takes place. However, I don't know how to do this. Sure, I could manually transform coordinates in my texture generation routine, and approximate the sphere with triangles and quads in my rendering routine, but I was wondering if there was a faster way to build something to be mapped to a sphere (preferably minimizing distortion) and to render it? Help would be appreciated.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Aken H Bosch
and approximate the sphere with triangles and quads in my rendering routine.



On videocards where triangles are the native rendering primitive, what else would you use?



Icosahedron's are pretty close to spheres if you tesselate them a lot...

Share this post


Link to post
Share on other sites
Numsgil    501
I've used a subdivided icosahedron with pretty good results (see this topic, especially my last post dated March 2 2007).

For texturing, basically what I do is assign texture coordinates to each of the 5 rectangular strips like they're just that-- rectangles. This would let you do things like texture splatting much the same way as more traiditional heightmapped terrain.

Share this post


Link to post
Share on other sites
Aken H Bosch    348
I came up with a solution that was kind of neither. It turned out I really didn't need a complete sphere, just several sometimes-overlapping regions that were never greater than half the size of the sphere.

My ingenious solution: I created a cartesian (rectangular) array of points, outside of the sphere, normalized them (so they all lay on the sphere's surface), rotated once to put it in the sphere's coordinate system, and then rotated a second time to get to the camera's coordinate system. I used additive blending (glBlendFunc(GL_ONE, GL_ONE)) to make the nebulae sort of transparent. Every object in the game so far is rendered additively, including the cursor, selection rectangle, stars, and nebulae.

Video

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this