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.