What does in opengl exactly means 'gl_FragDepth = 0.0'?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-16 17:18:08

问题


I'm saving the depth value via fragmend shader in the color buffer of the main framebuffer (in 'opengl es' there is no way to read the depth buffer via glReadPixels()). Additionally I need the maximum precision of 32-bit, that's why I use the rgba of the colorbuffer. But I realized that using also the alpha channel the results are not always correct, maybe because of some post fragmend operations. The following works:

  • set fragColor.a = 1 (but then I'm loosing one channel) or
  • set gl_FragDepth = 0.0 (works fine also with alpha != 1)

fragShader

void main(void) {
    gl_FragDepth = 0.0;//gl_FragCoord.z;
}

But why does this work if the depth value in depth buffer is always 0.0?

来源:https://stackoverflow.com/questions/50288912/what-does-in-opengl-exactly-means-gl-fragdepth-0-0

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