Results 1 to 6 of 6

Thread: [D3D] effect files v.s FVF formats

  1. #1

    [D3D] effect files v.s FVF formats

    Hallo PGD'ers.

    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.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    [D3D] effect files v.s FVF formats

    That's where you define the format of vertices.
    And the input to pixel shader.
    Code:
    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.
    Code:
    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.

  3. #3

    [D3D] effect files v.s FVF formats

    Quote Originally Posted by Dan
    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:
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  4. #4

    Re: [D3D] effect files v.s FVF formats

    Quote Originally Posted by chronozphere
    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.

    Quote Originally Posted by chronozphere
    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:

  5. #5

    [D3D] effect files v.s FVF formats

    Oh :eh: They've changed this feature of D3D. haven't they??

    Now it's something like this:
    [pascal]
    //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());
    [/pascal]

    I think i'll get used to this quickly.

    Thank you for your replies.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  6. #6

    [D3D] effect files v.s FVF formats

    If your VertexDecl / FVF contains less fields than required by shader - Draw[Indexed]Primitive() call will fail.
    There are only 10 types of people in this world; those who understand binary and those who don't.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •