PDA

View Full Version : Rear Viewing



SKA
02-19-2002, 07:21 PM
Hello,

I have a requirement to simulate Rear View Mirror. What is the technique involved in this concept?

Thanks.

dorbie
02-20-2002, 12:11 AM
Reverse the face winding or culling. Look at glCullFace.

Then just use a negative scale on the modelview at the right time in the right place to mirror the scene through the plane of the reflector. For an orthogonal view you could actually look back and reflect in eye space X.

A glViewport and glScissor for the mirror viewport on top of the forward view would help you then clear the depth buffer and draw as normal for the mirror.

If you want a mirror in the 3D scene it's a little trickier, you need to scale around the mirror plane, add a glClipPlane to the plane of the mirror (to be on the safe side) and probably just draw the mirror scene first then clear the depth buffer and fill the mirror plane surface to the depth buffer. Then you draw something like a sky dome to clear the rgb overdraw from the mirror. There are many ways to do this. I've given one which avoids stencil tests but there are popular ways which use the same geometry work but the rely on stencil testing to the mirror surface to draw the mirror scene last instead of first.