Jump to content
  • Advertisement
Sign in to follow this  
GambitSnax

Problems with spherical environment mapping

This topic is 4428 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using directx 9 and have been doing some environment mapping of late and have had some troubles with spherical mapping. For some reason the environment reflection gets rendered upsidedown and i'm not sure why. I've gotten cubic mapping working fine, but this problem has got me beat.
// constructing the sphere map texture
D3DXCreateTextureFromFileEx(g_pD3DDevice, "spheremap.jpg", 256, 256, 0, 0,
D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &g_pSphereMap);

// rendering
D3DXMATRIX matEnvironmentAdjust;

D3DXMatrixIdentity(&matEnvironmentAdjust);

g_pD3DDevice->SetTransform(D3DTS_TEXTURE0, &matEnvironmentAdjust);

g_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);

g_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_SPHEREMAP | 0);

g_pD3DDevice->SetTexture(0, g_pSphereMap);

g_pTorusMesh->DrawSubset(0);

Any suggestions would be greatly appreciated. Cheers.

Share this post


Link to post
Share on other sites
Advertisement
Well if it's getting rendered upside down then can't you just flip it?

Oh...an I don't think "D3DTSS_TCI_SPHEREMAP | 0" is any different from just "D3DTSS_TCI_SPHEREMAP".

Share this post


Link to post
Share on other sites
Well I could just flip the texture image and it would look fine, but I would rather implement the correct solution.

And yes, you don't need the 0 in the SetTextureStageState call. Thanks for that.

Share this post


Link to post
Share on other sites
reason:
see the "Spherical Environment Mapping" topic in the help document.
it says , fixed pipeline using following fomula.
u=Nx/2 + 0.5
v=Ny/2 + 0.5

and,"v" increase downward in the fixed pipeline.

solution:
flip the image. lol
some1 already said and u dont want this.but this is best and only solution if u create texture coord with D3DTSS_TCI_SPHEREMAP.

of course the solution is for fixed shader.
if u use programmable-shader,u can make any tex-coordinates on your own.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!