Page 1 of 1

'Static' Cube Mapping a Planet.

Posted: Tue Feb 21, 2006 8:15 pm
by Fost
Not too sure what the correct terminology is, but I'm trying to apply a cube map in a non 'environmental' way- i.e. fixed to the mesh, and unchanging with camera movement.

essentially - cube mapping a sphere with arbitrary geometry. 1024x1024 x 6 Cube Map gives us the same resolution as a 4096x4096 spherical map, so I'm hoping it can applied in this way. I've got a material with a cube map loaded, but I'm not sure what setting would be needed to make the texcoords work statically. Although env_map cubic_reflection does show everything up as working, how do I make the cube map 'fixed' to the surface? Or is this not possible?

Any ideas?

Posted: Wed Feb 22, 2006 12:10 am
by sinbad
You can do this, yes. Your mesh will need to have 3D texture coordinates (uvws, which OGRE supports in its mesh format - use VET_FLOAT3 instead of the more usual VET_FLOAT2 for texture coords), calculated as the normalised vector from the centre of the sphere, through the vertex in question. Bind a cubemap of the world and use those uvw's to address the texture.

It is, however, more expensive than the traditional approach of using a distorted 2D atlas style texture. Less distortion at the poles I'll admit though.

Posted: Wed Feb 22, 2006 12:31 am
by Fost
Thanks, I'll give that a go.

It's possible the sphere could be generated from a cube anyway so it would have 6 spherically distorted sides so we could use plain old 2d mapping. that would be faster and mroe compatible with older cards I guess.

-thanks again :)