Stencil mirror

Hi! I’d like to implement stencil based mirror in my program. The mirror will be a simple quad. I found lots of tutorials on the net about mirrors, but they are all using a mirror which is in the x,z plane. I want to use a mirror which can face any direction freely, so I think the solutions described in those tutorials won’t work for me. So here is how I plan to do it:

First I’ll set up stencil test and draw mirror mask into stencil buffer. Then I’ll mirror the camera’s position and direction to the plane of the mirror-quad. After that I’ll render the scene (onto the face of the mirror). Finally I’ll disable stencil test and draw the scene again using the original camera position and direction.

My question is that will this work or is there a better solution?

[This message has been edited by Catman (edited 03-17-2003).]

You got it, except you want to mirror the model matrix through the mirror plane and flip face cull winding. Conceptually mirroring the camera position doesn’t work (at least for me).

Yes, now that I think about it if there is an object behind the mirror and I mirror the camera position that object will appear in the mirror… Can you give me a link to some tutorials on mirroring the model matrix because I’m not very good at matrix math…