- Home /
Question by
jacasch · Sep 24, 2019 at 04:21 PM ·
shadershadersshaderlabgeometry shader
Is there a way to get an id of the primitive in a geometry shader?
Is there a way to get the ID of the current primitive in a geometry shader? Like you can do with SV_VertexID for vertices. (https://docs.unity3d.com/Manual/SL-ShaderSemantics.html) Apparently in DX11 and OpenGL there should be.
I tried SV_PRIMITIVEID and SV_PrimitiveID, and both didnt work.
Comment
Answer by pallagommosa · Feb 12, 2021 at 02:05 PM
You should be able to use it like this:
[maxvertexcount(3)]
void geom(triangle VertexOutput input[3], uint pid : SV_PrimitiveID, inout TriangleStream<VertexOutput> OutputStream)
{
// geometry shader implementation....
}