Recommended Posts

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

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.

0

Share this post

Link to post

Share on other sites

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.