Original Post
Hello,
I need to create several depth buffer (for each vertex emitted by a geometry shader) on my FBO.
Here the source code:
In fragment shader, I have:
Problem: the depth value is well written in my texture but the value is not right. Indeed, it seems that the value has not been affected by the depth test function: glDepthFunc(GL_LESS).
What can I do to solve this problem ?
Thank you in advance.
I need to create several depth buffer (for each vertex emitted by a geometry shader) on my FBO.
Here the source code:
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
//depth buffer 1
glTexImage2D( GL_TEXTURE_2D, 0, GL_R32F, shadowMapResolution, shadowMapResolution, 0, GL_RED, GL_FLOAT, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);
//depth buffer2
//....
In fragment shader, I have:
layout (location = 0) out float fragDepth;
void main()
{
fragDepth = gl_FragCoord.z / gl_FragCoord.w;
}
Problem: the depth value is well written in my texture but the value is not right. Indeed, it seems that the value has not been affected by the depth test function: glDepthFunc(GL_LESS).
What can I do to solve this problem ?
Thank you in advance.