Forum

Discarding vertices in geometry shader

i want to discard vertices in the geometry shader.

found a little example:

maxvertexcount(3)
void GS(
triangle VS_OUT vertices3,
inout TriangleStream<GS_OUT> outStream,
)
{
if (someCondition) // someCondition is a boolean that represents your condition
{
outStream.Append(vertices0);
outStream.Append(vertices1);
outStream.Append(vertices2);
}
else
{
// do not append to outStream, effectively discarding the output
}
}

concerning the conditions:

i saw a pic in the forum some time ago. seemed like cutting out vertices by texture. is this possible?

Yes it is. You can use SampleLevel to sample texture in VS or GS.

u can pretty much do the same in PS discarding pixels instead, i think that looks better

thx for replies! will try in pixelshader first. checked my openGL book, then found this:https://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/discard.php