Cascaded Shadow Map Geometry Shader Frustum Culling

Started by
2 comments, last by Alundra 9 years, 9 months ago

Hi all,

Using a geometry shader you can render using one draw call all partitions but you send triangle 4 times if you have 4 partitions.

Is it ok to stay with that or a frustum culling is needed to set the good index ?

What is the more efficient way ?

Thanks for the help

Advertisement

Using the geometry shader is more efficient for the CPU-side, because you only submit the commands once.

Not using the geometry shader is more efficient for the GPU-side, because you can do per-object culling via the CPU (and because GS's are often slow tongue.png).

One way is to draw multiple instances of each mesh depending in which frustums they are visible. The geometry shader can be used to define the output slice of a shadow texture array. This way the draw commands are submitted only once and the geometry shader is almost a simple pass through shader and no extra geometry is generated.

Cheers!

Here the geometry shader :


struct GS_OUTPUT
{
  float4 Position : SV_POSITION;
  uint RT_Index   : SV_RenderTargetArrayIndex;
};

cbuffer CASCADED_SHADOW_CBUFFER : register( b0 )
{
  float4x4 ViewProjection[4];
};

[maxvertexcount(12)]
void main(triangle float4 InPos[3] : SV_Position, inout TriangleStream<GS_OUTPUT> OutStream)
{
  for(uint i = 0; i < 4; ++i )
  {
    GS_OUTPUT Output;
    Output.RT_Index = i;
    for(int v = 0; v < 3; v++ )
    {
      Output.Position = mul(InPos[v], ViewProjection[i]);
      OutStream.Append(Output);
    }
    OutStream.RestartStrip();
  }
}

The culling has to be done here, since it's cascaded shadow, maybe the same code used to have the good cascade index can be used.

This topic is closed to new replies.

Advertisement