Spherical environment mapping formula

Started by
3 comments, last by tokaplan 18 years, 8 months ago
Anybody knows a formula for calculating texture coordinates for spherical environment mapping? SDK gives one, but it doesn't seem to work very well to me.
Advertisement
Try this:

D3DXMATRIX matRes = matWorld * matView;for( int i = 0; i < NumVertices; i++ ){    D3DXVECTOR3 N ( pvVertices.nx , pvVertices.ny , pvVertices.nz );    // Checking for back faces    if( N.x*matRes._13 + N.y*matRes._23 + N.z*matRes._33 > 0.0f )        continue;    // Assign the spheremap's texture coordinates    pvVertices.tu = ( 1.0f + ( N.x*matRes._11 + N.y*matRes._21 + N.z*matRes._31 ) ) * 0.5f;    pvVertices.tv = ( 1.0f - ( N.x*matRes._12 + N.y*matRes._22 + N.z*matRes._32 ) ) * 0.5f;}
Hmm.... Thank you, it works very well on large polygons, but on small ones reflection seems to be random and the environment map can not be recognized. May the polygon's size be a problem?
have you normalized your normals?
my-eulogy - A blog about coding and gfxsdgi - Semi-Daily Game IdeaChunkyHacker - Viewer for Relic chunky formats (used in DOW)
Yeah, I have... It looks so great on large polygons... But I need it on small ones (((

This topic is closed to new replies.

Advertisement