Sign in to follow this  

switching d3d texturecoordiantes

This topic is 3741 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 anyway to to change the way direct3d uses texture cooridnates? cuzz im gettin all confused with thinking one way and then have to rethink it in d3d... i find the d3d definition very illogical.. since origo is at bottom left in most coordinate systems?
from      =>   to

0.0-1.0       0.1-1.1
|    |    =>  |    |
0.1-1.1       0.0-1.0



Share this post


Link to post
Share on other sites
Quote:
Original post by Dragon_Strike
is there anyway to to change the way direct3d uses texture cooridnates? cuzz im gettin all confused with thinking one way and then have to rethink it in d3d... i find the d3d definition very illogical.. since origo is at bottom left in most coordinate systems?


You can reorient texture coordinates using the texture matrix in fixed-function processing or your vertex shader in programmable processing. I describe the vertex processing applied to texture coordinates in Chapter 11. Basic Texturing from my book.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dragon_Strike
thx... but i dont rly understand it...


Do you understand how a matrix works to transform a point from one coordinate system to another?

That's what the texture matrix does, except instead of transforming the position of a vertex like the world matrix, it transforms the texture coordinates. Each texture stage has its own matrix that can be applied to the texture coordinates before they are used to sample a texture.

Share this post


Link to post
Share on other sites
In managed Direct3D, call IDirect3DDevice9::SetTransform to set the texture transformation matrix:

device.SetTransform(TransformType.Texture0, matrix);
Here, Texture0 specifies that the transformation is to be applied to the first (index 0) texture stage. This code won't do anything, though, unless you enable transformation of texture coordinates using:

device.SetTextureStageState(0, TextureStageStates.TextureTransform, (int) TextureTransform.Count2);

I've assumed you're using 2D textures. If not, change the Count2 as appropriate. The process is analogous in unmanaged DirectX.

In order to invert the v-axis, you'll want the following matrix:

1  0  0  0
0 -1 0 1
0 0 1 0
0 0 0 1


Admiral

Share this post


Link to post
Share on other sites

This topic is 3741 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.

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