Advertisement Jump to content


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


Texture coordinate problem

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

Yesterday I was having some problems setting up the texture stages to modulate one texture with another (see my post Multitexturing Problem from 01-16-04). I got that figured out, but the problem that I''m having now is that I can''t get the texture coordinates right for stage 1. No matter what values I use for my second set of texture coordinates, it uses 0,0 for stage 1. I know this is the case because when I had a white pixel in the upper left hand corner of my texture, texture stage 1 seemed to have no effect (because I was multiplying by 1 since the pixel is white). When I changed the upper left hand pixel to red, the image looks red, so I came to the conclusion that texture stage 1 is using 0,0 for the texture coordinates, no matter what coordinates I specified. Here is my FVF definition #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL| D3DFVF_DIFFUSE|D3DFVF_TEX2|D3DFVF_TEXCOORDSIZE2(0)|D3DFVF_TEXCOORDSIZE2(1)) and my CUSTOMVERTEX struct looks like this struct CUSTOMVERTEX { D3DXVECTOR3 position; // vertex position D3DXVECTOR3 normal; // vertex normal D3DCOLOR color; // The color FLOAT tu, tv; // The texture coordinates FLOAT tu2, tv2; // The second set of // texture coordinates. }; I am filling the vertex buffer like this verticies[0].position = D3DXVECTOR3(0, 1.5, 0); verticies[0].normal = D3DXVECTOR3(0, 0, -1); verticies[0].color = D3DCOLOR_RGBA(255, 0, 0, 85); verticies[0].tu = 0; //coordinates for stage 0 texture verticies[0].tv = 1; verticies[0].tu2 = 0; //coordinates for stage 1 texture verticies[0].tv2 = 1; For the other verticies I used texture coordinates (1,1) and (0,0). What else to I have to do to get DirectX to recognize and use my texture coordinates for stage 1? Thanks.

Share this post

Link to post
Share on other sites
I forgot to mention that I also set the texture coordinate index of each stage like this...

m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);

I know it''s not a problem with my texture because it works fine if I set stage 1 to use the same set of texture coordinates as stage 0. like this...

m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0);

The problem with that is that I can''t use different sets of texture coordinates for each stage.

Share this post

Link to post
Share on other sites
I just figured it out.

Somehow I accidentally deleted this line.


Since I wasn''t calling SetFVF, DirectX didn''t know about the 2nd set of texture coordinates, so it was defaulting to (0,0).

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!