I’ve been reading through the OpenGL ES Shading language specification and there is a section that puzzles me:
7.2 Fragment Shader Special Variables
…
It is not a requirement for the fragment shader to write to either gl_FragColor or gl_FragData. There are
many algorithms, such as shadow volumes, that include rendering passes where a color value is not
written.
I’ve looked at plenty of articles on shadow volumes and shaders and I can’t find any information on how these algorithms can do anything without writing a colour value as there does not seem to be a way of returning data from the vertex shader alone on the ES platform. Desktop GL has geometry shaders which seem to be for this kind of effect, but there is no such thing in ES 2.0 Core.
Is this something that was inadvertently left in from the desktop specification, allowing for extensions or have I just missed something?
I wrote some weeks ago a shadow volume algo with opengl es 2.0.
For this purpose, in some passes, you don’t write the color.
For example, you must work with the stencil buffer, with incrementing/decrementing the stencil based on the visible/not visible faces and the silouhette. When you do this work, you must disable the color (GLES20.glColorMask(false, false, false, false);).
If you don’t, you will have a lot of artefacts.
The goal here is to update the stencil without updating color (fragment buffer).
More detailed informations on shadow volume and why you need disable color :
http://http.developer.nvidia.com/GPUGems/gpugems_ch09.html
(Sorry for my poor english) 🙂