• FEATURED
• FEATURED
• FEATURED
• FEATURED
• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1leonard2012  Members

Posted 16 December 2012 - 08:12 AM

Nearly every geometry shader reference says that GS can create or destroy primitives, and gives examples on how to add or change geometries, but few of them show how to discard primitives. Could anyone offer some hint on this? thanks.

### #2Nik02  Members

Posted 16 December 2012 - 01:44 PM


[maxvertexcount(3)]

void GS(

triangle VS_OUT vertices[3],

inout TriangleStream<GS_OUT> outStream,

)

{

if (someCondition) // someCondition is a boolean that represents your condition

{

outStream.Append(vertices[0]);

outStream.Append(vertices[1]);

outStream.Append(vertices[2]);

}

else

{

// do not append to outStream, effectively discarding the output

}

}



Niko Suni

### #3Nik02  Members

Posted 16 December 2012 - 01:47 PM

It is worth noting that you can evaluate the "someCondition" on the GS logic itself; for example, calculate the geometric normal of the current triangle and compare it to some direction in which you want to do custom culling against.

Edited by Nik02, 16 December 2012 - 01:48 PM.

Niko Suni

### #4leonard2012  Members

Posted 16 December 2012 - 08:55 PM

[maxvertexcount(3)]
void GS(
triangle VS_OUT vertices[3],
inout TriangleStream<GS_OUT> outStream,
)
{
if (someCondition) // someCondition is a boolean that represents your condition
{
outStream.Append(vertices[0]);
outStream.Append(vertices[1]);
outStream.Append(vertices[2]);
}
else
{
// do not append to outStream, effectively discarding the output
}
}


Thanks. I'll try the method.

### #5Nik02  Members

Posted 17 December 2012 - 05:35 AM

The key point here is that you explicitly need to append the primitives to your output stream to get anything out of GS to begin with. If you simply do not do the appending, the results of the current GS invocation will effectively be discarded.

Niko Suni

### #6leonard2012  Members

Posted 17 December 2012 - 08:42 AM

The key point here is that you explicitly need to append the primitives to your output stream to get anything out of GS to begin with. If you simply do not do the appending, the results of the current GS invocation will effectively be discarded.

Thanks. It works.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.