Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

switching d3d texturecoordiantes

This topic is 4104 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
Advertisement
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
Texture coordinates in D3D is similar to screen space - that is, the pixel (0,0) is at the top left of your screen. Same for textures.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!