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

天大地大妈咪最大 提交于 2019-12-10 02:36:29

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/9503538/can-an-opengl-es-fragment-shader-change-the-depth-value-of-a-fragment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!