• Advertisement
Sign in to follow this  

Cascaded Shadow Map Geometry Shader Frustum Culling

This topic is 1385 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement