How to draw a transparent polygon in OpenGL-ES 2.0?

I want to draw a translucent (say alpha = 0.5) polygon in openGL-es 2.0. How to do it?. A few things I have tried. 1. I made gl_Fragcolor.w = 0.5 in the fragment shader. 2.Disabled Deep things.

I do not know how to enable blending in openGL-es 2.0. I read it somewhere, it runs automatically. This is true?. Any little help is appreciated.

+4
source share
1 answer

You must enable alpha blending. FAQ on how to do this: https://www.khronos.org/opengl/wiki/Transparency_Sorting .

To enable the desired effect:

glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 

Please note that enabling alpha blending will slightly decrease performance, so only do this on triangles for which alpha blending is required.

+10
source

All Articles