PDA

View Full Version : Mirrors



KRONOS
09-20-2002, 05:37 AM
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?

Sy
09-20-2002, 09:44 AM
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.

dorbie
09-20-2002, 11:13 AM
You build a reflection matrix around the plane of the mirror and multiply that on the modelview immediately after view xform is applied.

You need to reverse face winding or face culling in the reflected version.

You also need to clip the scene to the plane of the mirror or at least cull objects in front of the mirror surface. It depends on circumstances.

Another thing you might consider is stencil testing to the mirror surface but this isn't always required.

Lucky
09-20-2002, 09:57 PM
Originally posted by KRONOS:
The thing is I don't want it to be like rendering to texture. It wouln't look good.

Why wouln't it look good?

Pentagram
09-21-2002, 05:04 AM
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.

timmie
10-09-2002, 10:13 AM
Do you know of any good tutorials on textured mirrors? Sounds like that's probably the way I'll go for the mirrors in my project.