I am trying to make a thin g-buffer using this tutorial. My rendering code is almost identical apart from the fact that I removed the specular map.
It seems that I get normal and position maps, but they seem to have a weird (transparency/rendering order?), for example, the normal map shows both the back and the front at the same time.
Model:
G-Buffer normal map:
For example, you can see the three circles and wires that are on the back of the model.
If I use glCullFace(GL_BACK); it improves slightly.
G-Buffer normal map with face culling:
Are you still rendering this geometry with both depth test and depth writes? The behavior you’re seeing suggests that maybe you’re not, but you should be.
Is this model intended to be rendered with backface culling or not? That is, which sides of the tris should render – one or both? For this model, my guess would be one-side so backface culling on, but consult your model’s render state to be sure… Render your G-Buffer with the appropriate cullface for the surface.
Also, with two-sided surfaces (no backface culling), it’s expected that the surface normal be flipped toward the viewer for lighting purposes. I would assume something similar should probably be done for normal maps as well. That said, I doubt this is surface is modeled to render with two-sided surfaces.
The problem really turned out to be in the depth writes, it turned out that I accidentally bound the default buffer with “glBindFramebuffer(GL_FRAMEBUFFER, 0);” right before the generating renderbuffer and attaching GL_DEPTH_ATTACHMENT.
Now I feel stupid for such a simple mistake.
Thanks for the help!
Hey, don’t feel stupid. It happens to everyone. The more experience you get with rendering bugs, the more often your intuition points you straight to the problem.