Original Post
🔒 Locked
Texture Vertex Format?
Advertisement
The macro is D3DFVF_TEXCOORDSIZEn(m), where:
- n is the number of floating point values for this texture stage
- m is the texture stage these coordinates are for (the same as the stage parameter for SetTexture and SetTextureStageState).
So if I had a vertex format set for some primitive involving 3 textures all of which needed their own unique texture coordinates:
typedef struct
{
float vx, vy, vz;
float nx, ny, nz;
...
float tex1_u, tex1_v; // texture stage 0, 2D texture
float tex2_u; // texture stage 1, 1D texture
float tex3_u, tex3_v, tex3_w; // texture stage 2, 3D/cube texture
}
MYVERTEX;
The FVF would include:
D3DFVF_TEXCOORDSIZE2(0) | // stage 0 = 2D coordinates
D3DFVF_TEXCOORDSIZE1(1) | // stage 1 = 1D coordinates
D3DFVF_TEXCOORDSIZE3(2) // stage 2 = 3D coordinates
Another example if I had a primitive using 2 1D textures:
typedef struct
{
float x,y,z;
...
float tex1_u;
float tex2_u;
}
MYOTHERVERTEX;
Your FVF would contain:
D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEXCOORDSIZE1(1)
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
- n is the number of floating point values for this texture stage
- m is the texture stage these coordinates are for (the same as the stage parameter for SetTexture and SetTextureStageState).
So if I had a vertex format set for some primitive involving 3 textures all of which needed their own unique texture coordinates:
typedef struct
{
float vx, vy, vz;
float nx, ny, nz;
...
float tex1_u, tex1_v; // texture stage 0, 2D texture
float tex2_u; // texture stage 1, 1D texture
float tex3_u, tex3_v, tex3_w; // texture stage 2, 3D/cube texture
}
MYVERTEX;
The FVF would include:
D3DFVF_TEXCOORDSIZE2(0) | // stage 0 = 2D coordinates
D3DFVF_TEXCOORDSIZE1(1) | // stage 1 = 1D coordinates
D3DFVF_TEXCOORDSIZE3(2) // stage 2 = 3D coordinates
Another example if I had a primitive using 2 1D textures:
typedef struct
{
float x,y,z;
...
float tex1_u;
float tex2_u;
}
MYOTHERVERTEX;
Your FVF would contain:
D3DFVF_TEXCOORDSIZE1(0) | D3DFVF_TEXCOORDSIZE1(1)
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
Thank you for your answering.
But I have met this problem,
struct MYVERTEX {
float x, y, z, rhw;
float u, v;
};
I use this vertex format (D3DFVF_XYZRHW | D3DFVF_TEX1)
Because I want to use 1D Texture, so under this format, I create a 1 pixle height texture, and let the second texel coordinate be zero. Then the rendering is Ok.
But when I changed the vertex format to (D3DFVF_XYZRHW | D3DFVF_TEXTURESIZE2(0)), it renders wrong.
And also I changed to another vertex format that is a 1D texture.
struct MYVERTEX {
float x, y, z, rhw;
float u,
};
(D3DFVF_XYZRHW | D3DFVF_TEXTURESIZE1(0)) and the texture also was create with 1 pixel height.
But it failed to create the vertex buffer. I don''t know why.
But I have met this problem,
struct MYVERTEX {
float x, y, z, rhw;
float u, v;
};
I use this vertex format (D3DFVF_XYZRHW | D3DFVF_TEX1)
Because I want to use 1D Texture, so under this format, I create a 1 pixle height texture, and let the second texel coordinate be zero. Then the rendering is Ok.
But when I changed the vertex format to (D3DFVF_XYZRHW | D3DFVF_TEXTURESIZE2(0)), it renders wrong.
And also I changed to another vertex format that is a 1D texture.
struct MYVERTEX {
float x, y, z, rhw;
float u,
};
(D3DFVF_XYZRHW | D3DFVF_TEXTURESIZE1(0)) and the texture also was create with 1 pixel height.
But it failed to create the vertex buffer. I don''t know why.
D3DFVF_TEX1 tells D3D *how many* **SETS** of texture coordinates your vertex format has.
So if you have 1 set of texture coordinates for a 1D texture, your FVF would be:
D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_TEXTURESIZE1(0)
If you had 2 sets of texture coordinates, the first stage being 3D coordinates and the second stage being 1D coordinates your FVF would look like:
D3DFVF_XYZRHW | D3DFVF_TEX2 | D3DFVF_TEXTURESIZE3(0) | D3DFVF_TEXTURESIZE1(1)
The D3DFVF_TEXTURESIZE tells D3D how many values to use for each texture stage. The D3DFVF_TEX tells D3D how many stages that vertex is for.
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
So if you have 1 set of texture coordinates for a 1D texture, your FVF would be:
D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_TEXTURESIZE1(0)
If you had 2 sets of texture coordinates, the first stage being 3D coordinates and the second stage being 1D coordinates your FVF would look like:
D3DFVF_XYZRHW | D3DFVF_TEX2 | D3DFVF_TEXTURESIZE3(0) | D3DFVF_TEXTURESIZE1(1)
The D3DFVF_TEXTURESIZE tells D3D how many values to use for each texture stage. The D3DFVF_TEX tells D3D how many stages that vertex is for.
--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement