Can an OpenGL ES shader change a fragment depth value?

Is it possible to fragment a shader in OpenGL ES 2.0 to change the value of Z (depth) of a pixel?

How is this achieved in OpenGL ES 2.0?

+9
source share
2 answers

No - gl_FragDepth (which is part of the desktop version of GLSL) is missing in OpenGL ES.

However, you can check for GL_EXT_frag_depth . If available, you can write the depth to gl_FragDepthEXT .

The document contains more detailed information on how to enable the extension, etc.

+10
source

Although gl_fragDepth not available in OpenGL ES 2.0, it is available starting with version 3.0 and higher , so the update will be correct if you do not need to use an older version for compatibility.

0
source

All Articles