Can an OpenGL ES fragment shader change the depth value of a fragment?
Asked Answered
T

2

9

Can fragment shader in OpenGL ES 2.0 change the Z value (depth) of a pixel?

How is this achieved in OpenGL ES 2.0?

Templia answered 29/2, 2012 at 17:11 Comment(1)
See also: Writing texture data onto depth bufferImminent
J
10

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

You can, however, check for the existence of GL_EXT_frag_depth. If it's available, then you can write the depth to gl_FragDepthEXT.

The extension paper gives more details about how to enable the extension and such.

Jetsam answered 29/2, 2012 at 17:43 Comment(1)
Does anyone have a list of hardware that supports GL_EXT_frag_depth?Helbonnah
H
0

While gl_fragDepth is not available in OpenGL ES 2.0, is is available from version 3.0 onwards, so upgrading would be the way to go unless you need to use the older version for compatibility.

Herr answered 24/6, 2019 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.