Clockworkcoders Tutorials
|
Discarding FragmentsIt is possible to tell the fragment shader it shouldn't write any pixel. This can be done using the "discard" statement. This can be used - for example - to implement a color key. Using the following texture, all red pixels should be removed (discarded!).
If you start the shader you will get the following result:
There are still some red pixels visible. This is because the texture was filtered. This can be prevented by setting the texture parameters to: glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
This time it looks better.
|
![]()

