PDA

View Full Version : [D3D] effect files v.s FVF formats



chronozphere
14-05-2007, 07:28 PM
Hallo PGD'ers. 8)

I have been reading things about effect-files lately and i didn't found any information about FVF formats. Shaders need info like diffuse, specular and texture coords for each vertex.
What if certain FVF data is used in the effect-file, but isn't present in the mesh that is to be rendered with it.

Will the missing data be replaced by zero's or will i get an error?? Are there routines available to find out which FVF attributes a mesh must have, when using that shader??

Thank you. ;)

Dan
14-05-2007, 09:51 PM
That's where you define the format of vertices.
And the input to pixel shader.


struct TVertex {
float4 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
};
struct TPixel {
float4 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
float2 TexCoord1 : TEXCOORD1;
float4 TexCoord2 : TEXCOORD2;
};

And here you send input in the format that you have defined.


void VS(in TVertex Input, out TPixel Output)
{
...
}

That is all in .fx file so all you need to do is make sure you arrange your vertex buffers in the format that the vertex shader would understand.

Shaders normally dont give any errors, so if the input data is missing it may either be replaced with "rubish" or zeros.

JSoftware
14-05-2007, 10:26 PM
Shaders normally dont give any errors, so if the input data is missing it may either be replaced with "rubish" or zeros.
Bolded for emphasis :lol:

LP
14-05-2007, 11:10 PM
What if certain FVF data is used in the effect-file, but isn't present in the mesh that is to be rendered with it.
The result is most likely unpredictable. You should not rely on it. Check that the mesh vertex declaration has all necessary fields before passing it to shader, or use a different shader that doesn't need these fields.



Will the missing data be replaced by zero's or will i get an error?? Are there routines available to find out which FVF attributes a mesh must have, when using that shader??
Not really. You should check both the shader code and the vertex declaration of your mesh to make sure that both can function together.

Also, if you are using shaders, why do you still use FVF? :shock:

chronozphere
15-05-2007, 05:51 AM
Oh :eh: They've changed this feature of D3D. haven't they??

Now it's something like this:

//set up Vertex Shader (NEW)
D3DVERTEXELEMENT9 decl[] = ((0,
0,
D3DDECLTYPE_FLOAT3,
D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_POSITION,
0),
(0,
12,
D3DDECLTYPE_FLOAT2,
D3DDECLMETHOD_DEFAULT,
D3DDECLUSAGE_TEXCOORD,
0),
D3DDECL_END());


I think i'll get used to this quickly. ;)

Thank you for your replies. ;)

Clootie
15-05-2007, 10:26 PM
If your VertexDecl / FVF contains less fields than required by shader - Draw[Indexed]Primitive() call will fail.