discard_fragment in shader discards all fragments?

I've been trying to write a fragment shader which draws a circle within a quad, by measuring the distance from the center. I've verified that my calculations are correct, and it works if I set the alpha value to 0 where I don't want pixels drawn. But if I try using discard_fragment() instead of setting the alpha to zero, then *none* of the pixels get drawn. It's like one call to discard_fragment causes all of the pixels for the entire triangle to be discarded.


That's not supposed to happen, is it? Is there a bug or am I doing it wrong somehow?

Thanks

Replies

discard_fragment() should only affect the fragments on which you call it. So, if block it's in a if statement and the predicate of the if statement is false for the fragment, it should be drawn. (Note that discard_fragment() completely orthogonal to the values of the pixels you're drawing, so it doesn't matter if alpha channel or the fragment you're returning is 0 or not. If it gets called the fragment doesn't draw and conversily if it doensn't get called, your fragment should draw regardless of alpha)