Let’s say I am rendering a mirror surface on a flat convex surface. I use the edges of the surface to create clipping planes around the camera, move the camera in a position so that a reflection is rendered, then draw and move the camera back.
The only problem is that objects still get drawn behind the “mirror”. To make the “mirror” occlude objects that lie behind it, I rendered the surface with glBlendFunc set to GL_ZERO,GL_ZERO. This works pretty well, but I still get some graphical glitches, with objects behind the mirror flashing on and off as I move.
Is there a better way to make OpenGL think I drew an object on that surface, even though I just drew a clipped view from a different camera angle?
Here is an image of what I am doing. Here, I am actually using the same technique to render the skybox. There is a block of “sky” sitting on the road on the right. You can see the sky through it, and it blocks objects that are behind it. However, when I move around, there are some flashes of other objects on top of the sky surfaces.
if you just want depthwrithing turn colormask to false
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)
you will get a speed boost on most hardware I think, as they are faster on pure zpasses.
with glColorMask you say to which color channels you want to render. giving all false makes that nothing will be displayed, but it was rendered to depth buffer (if you don’t disable that too)