Sign in to follow this  
L. Spiro

OpenGL Automatic Texture Coordinate Generation?

Recommended Posts

I have heard rumors of it in DirectX 9.0c but can not find any information. For example: http://msdn.microsoft.com/en-us/library/bb206247(VS.85).aspx At the bottom it reads, “Automatically Generated Texture Coordinates (Direct3D 9)”, but there is no link! So basically I want to do shadow-mapping in a way as closely related to the OpenGL FFP method as possible. My engine supports both, and so the methods should be as similar as possible. Additionally, the OpenGL version of my engine works on iPhones and iPod touches, which means no shaders. So how is shadow-mapping done in DirectX (FFP)? I am really looking for a way to perform the automatic texture coordinate generation so that the method can really match my OpenGL implementation in a generic way. That is, I can make a class that simply performs all the state changes needed to make shadow mapping work and just change how it works in OpenGL and DirectX, but it is much more flexible to instead make wrappers for the smaller parts and use the shadow-mapping class to bring them together, without itself needing to change for each graphics API. Specifically I want to do this (if possible) so that new graphics techniques can be supported in the future without needing the source code of my engine. So, is there a one-for-one way to do the FFP OpenGL shadow-mapping technique in DirectX? Thank you, L. Spiro

Share this post


Link to post
Share on other sites
Nevermind.

After years of searching I stumbled upon this:
http://msdn.microsoft.com/en-us/library/bb172621(VS.85).aspx

I wonder why all links in other areas of MSDN that refer to automatic texture-coordinate generation are invalid/missing.


L. Spiro

Share this post


Link to post
Share on other sites
Actually I have a question.

Reading about D3DTSS_TEXCOORDINDEX, it says this:
With the exception of D3DTSS_TCI_PASSTHRU, which resolves to zero, if any of the following values [there are no following values] is included with the index being set, the system uses the index strictly to determine texture wrapping mode. These flags are most useful when performing environment mapping.

This really just confuses me.


What I want is to simulate the OpenGL system of being able to set coordinate generation on a per-component basis.

For example, I want to set the SRT coordinates to eye-linear and leave Q default in texture slot 2.
In OpenGL:
::glClientActiveTexture( GL_TEXTURE0 + 2 );
::glEnable( GL_TEXTURE_GEN_S );
::glEnable( GL_TEXTURE_GEN_T );
::glEnable( GL_TEXTURE_GEN_R );
::glDisable( GL_TEXTURE_GEN_Q );
::glTexGenf( GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
::glTexGenf( GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
::glTexGenf( GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );


In DirectX (no clue here, this is where you come in):
IDirect3DDevice9::SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, (0 | D3DTSS_TCI_CAMERASPACEPOSITION) );
IDirect3DDevice9::SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, (1 | D3DTSS_TCI_CAMERASPACEPOSITION) );
IDirect3DDevice9::SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, (2 | D3DTSS_TCI_CAMERASPACEPOSITION) );
IDirect3DDevice9::SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, (2 | D3DTSS_TCI_PASSTHRU) );


Okay it is obvious that the last call is going to destroy everything the previous 3 calls did, so this is clearly not the way to get the same result as in OpenGL.
Anyone know how to do it?


Thank you,
L. Spiro

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