I have this problem: I have to put a mirror in my scene. The thing is I don’t want it to be like rendering to texture. It wouln’t look good. The effect I’m after is like the mirrors in Quake3.
I don’t know for sure, but I think Quake renders the scene from the mirror point of view, then renders the mirror from the camera point of view to the stencil buffer, and finally renders the scene again from the camera point of view, where the stencil wasn’t updated.
This method doesn’t sound good, but I think it would work. Can someone give me a better aproach?
Probably the easiest way to do mirrors is this:
1, Render the mirrored scene, this means do something like glScalef(-1,1,1); then draw all objets
2, Draw all objects normally
This will result in mirror-like effect along yz plane. Using stencil buffer (or depth buffer if you’re good enough) you can mirror the scene only in the place where mirror should be.
There are some more things you have to do, but I hope you understand the basic mechanism.
The original quake used DepthRange to render it’s mirrors. I guess quake3 uses the same method. (I looks the same.)
It did
glDepthRange(0,0.5)
render scene
glDepthRange(0.5,1)
render scene
glDepthRange(0,0.5)
blend mirror polygons
I personally think textured mirrors are better since you can easily have transparant mirrors (a.k.a glass) and such.