Skip to main content
gamedev.net
🔒 Locked

Texture coordinate problem

Started by Chadivision Jan 17, 2004 at 10:13 AM 2 replies 400+ views
Original Post
Chadivision
Chadivision
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.
Atari 2600 Homebrew Author - Someone who is smart enough to learn 6502 assembly language but dumb enough to actually want to use it.
Chadivision
Chadivision
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.


Atari 2600 Homebrew Author - Someone who is smart enough to learn 6502 assembly language but dumb enough to actually want to use it.
neneboricua19
neneboricua19
Are you sure you''re creating a vertex buffer of the correct size? Can you post the code you use to create and initialize your vertex buffer?

neneboricua
Chadivision
Chadivision
I just figured it out.

Somehow I accidentally deleted this line.

m_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);

Since I wasn''t calling SetFVF, DirectX didn''t know about the 2nd set of texture coordinates, so it was defaulting to (0,0).
Atari 2600 Homebrew Author - Someone who is smart enough to learn 6502 assembly language but dumb enough to actually want to use it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.