Question regarding GLSL discard instruction

Hi list!

I am currently working on the development of an SGX OpenGLES 2.0 3D application.
The application was initially created using OpenGLES 1.1. At this time, we were using alpha ref and alpha textures, which worked just fine. The behaviour looks like discard is used in the fixed function pipeline (i.e. zBuffer not updated if alpha<alphaRef)

Now that we want to use OpenGLES 2.0 we would like to get the same results with shader programs. How can I achieve this without using the discard instruction ? (I tried setting the gl_FragColor.a = 0.0, but it requires triangles to be sorted, which can’t be achieved)

Does anyone have an idea ?

Thanks,
Florent.



discard is the OpenGL ES 2.0 equivalent of alpha test. You cannot achieve the same result without discard.

If you were working with a POWERVR under OpenGL ES 1.1 then using alpha test would still be less than ideal for performance already. As Xmas says, you can’t achieve the same effect without sorting transparent triangles, but you may find sorting these and using blending may help the performance of the graphics core on both implementations, but at the price of some CPU load. If you have (or want) any partially transparent polys that need blending and had to sort these anyway then it might be fairly easy to prototype this approach and see.





I suppose it comes down to whether the CPU or the GPU is limiting your application.