Setting Matrices for Texture Coordinate Generation

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

Recommended Posts

So if I use:
IDirect3DDevice9::SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, (1 | D3DTSS_TCI_CAMERASPACEPOSITION) );
How do I set the matrix it uses to generate these coordinates? If I am going to do shadow-mapping I want the coordinates to be transformed as a projection from the light source. So I need a way to set the matrix values to be used with this automatic generation. L. Spiro

Share on other sites
You'll want to set stage 1's D3DTSS_TEXTURETRANSFORMFLAGS to D3DTTFF_COUNT4 | D3DTTFF_PROJECTED to activate the matrix and projection mode. And to set the matrix, you use SetTransform(D3DTS_TEXTURE1, &matrix);. Remember to set the texture transform flags back to D3DTTFF_DISABLE when you're done, so as not to muck up any other code using a texture in stage 1.

NOTE: I'm not guaranteeing the accuracy of the names provided, as it's from memory, but the help and/or Intellisense will quickly fix any misspellings for you.