CG: How to NOT write the pixel

Hi Guys,

This is really a CG question. I’m adding a clipping rectangle to an existing Cg shader. If the coordinates of the pixel are
outside of the clipping rectangle I want nothing written to the screen or z-buffer.

Question: How can I tell a fragment shader to abort writing a pixel? Is there some kind of special Color I can return or a method I can call within the frag shader to end processing of that pixel?

I suppose I could force the depth to be outside of the clip range, but is there a cleaner way?

Ah… it appears there is a discard command.

Trying it now…

Yes, saying the command discard; in the frag shear prevents the pixel from being drawn.