0

I am trying to add a Geometry Shader to my DirectX 11 project in C++

There are no examples of this anywhere I look. There are millions of tutorials on OpenGL but nothing on geometry shaders in DirectX

I just wrote a basic shader below, but I get the following error when trying to build it

error X3514: 'LightGeometryShader' must have a max vertex count

Can anyone please advise on what this shader is missing to be able to compile?

////////////////////////////////////////////////////////////////////////////////
// Filename: light.gs
////////////////////////////////////////////////////////////////////////////////


//////////////
// TYPEDEFS //
//////////////
struct GeometryInputType
{
    float4 position : POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
};

struct PixelInputType
{
    float4 position : SV_POSITION;
    float2 tex : TEXCOORD0;
    float3 normal : NORMAL;
};


////////////////////////////////////////////////////////////////////////////////
// Geometry Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType LightGeometryShader(GeometryInputType input)
{
    PixelInputType output;
    
    output = input;

    return output;
}

1 Answer 1

1

GeometryShader is not necessarily a 1:1 function, which is why you have to provide a max vertex count. See Microsoft Docs.

[maxvertexcount(3)]
void LightGeometryShader( triangle GeometryInputType input[3],
    inout TriangleStream<PixelInputType> outStream )
{
    PixelInputType output;
    for( int v = 0; v < 3; v++ )
    {
        output.position = input[v].position;
        output.tex = input[v].tex;
        output.normal = input[v].normal;
        outStream.Append( output );
    }
}

Geometry Shader was introduced with Direct3D 10, so the bulk of the deved samples were in the legacy DirectX SDK at the time. You can find the latest copy of these samples buildable without the legacy DirectX SDK on GitHub.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.