Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


D3D8 Texture coordinates

This topic is 6312 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

Is there a way to use the position/normal coordinates as texture coordinates for a cubemap in d3d8 before they are transformed into camera space (object or worldspace) without including any extra texture coordinates in the FVF. Like D3DTSS_TCI_CAMERASPACENORMAL or D3DTSS_TCI_CAMERASPACEPOSITION but before they are transformed by the view matrix. It would help me alot if it did. Maybe it''s possible if you use the same vertexbuffer in different streams... But I don''t know at all if that is possible.

Share this post

Link to post
Share on other sites
The first part - you could do this easily in a vertex shader, but I''m pretty sure you''d still have to include the texture coordinates in your FVF (although you wouldn''t have to supply values). Basically, the shader would include a line like:

mov oT0.xy, v0.xy

The second part - I don''t think SetStreamSource has a problem with reusing buffers, but I don''t understand how that would help you. Please explain.

Share this post

Link to post
Share on other sites
I obviously forgot to mention that I don''t want to use vertex shaders. I want to use fixed function pipeline as much as possible.

But if it is possible to reuse buffers than I could split the FVF in separate streams and use the normalbuffer twice, second time as a texture coordinate stream.
Dunno if this is really a better idea than using extra texture coordinates that duplicate that normal coordinates.

Share this post

Link to post
Share on other sites
"D3DTSS_TCI_CAMERASPACE" kindof implies what space you''re going to get generated for you, so theres no other flag to specify world/object space...

...what you can do however is transform the resultant coordinates back into world space by bunging the inverse of the view matrix into a texture transform - (think of the inverse as being an "undo" matrix ) - the following works fine for example:

D3DXMATRIX mView, mInvView;
float det = 0.0f;

pDevice->GetTransform( D3DTRANSFORMSTATE_VIEW, (D3DMATRIX*)&mView );

if (D3DXMatrixInverse(&mInvView, &det, &mView))
pDevice->SetTransform( D3DTRANSFORMSTATE_TEXTURE1, (D3DMATRIX*)&mInvView );


pDevice->SetTexture( 1, pMyCubeMap );

The matrix inverse and the GetTransform can be costly - with knoweldge of how your own particular view transform has been built you should be able to make it much cheaper (such as using a transpose directly).

Simon O''''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites
You are absolutly right... that should work. Nice.

Though it feels kinda backwards...

I already calculate the inverse view matrix and the world matrix will be the identity so that''s no problem.

I can''t believe I didn''t think of this.
I need to cut down on the partying...

Anyway, big thanks to you.

Share this post

Link to post
Share on other sites

  • 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!