Sign in to follow this  
GambitSnax

Spherical Mapping queries

Recommended Posts

I'm working on implementing environment mapping atm and have come across some problems with my spherical mapping. I can get an object to render a spherical environment map, but the reflection it generates is upside down and flipped vertically. I'm not sure as to why this is happening. I have cubic mapping working in the same scene and it renders fine. Here is some of the code I use for spherical mapping

// load the sphere map into the g_pSphereMap object
D3DXCreateTextureFromFileEx(g_pD3DDevice, "spheremap.jpg", 256, 256, 0, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &g_pSphereMap);

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

g_pD3DDevice->SetTexture(0, g_pSphereMap);


And then I render my object. Can anyone suggest why it might be acting like this? Just an added question, as far as I understand, a spherical map works only for one point in space. So you can't move the object around and expect it to reflect correctly. Does this one point in space also mean just one perspective, aka one direction of view at the object, or should you be able to rotate around the object and see the reflection. I'm thinking you should but i'm not sure how to pass the translations into the texture coordinate generation. Cheers for your help.

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