View Full Version : Creating a Mirror
11-14-2004, 09:04 AM
I have a surface. How to make a mirror, which will reflect other objects?
Question i suppose is big,so the link to source will be qood too.
11-14-2004, 10:05 AM
It is not as simple as "I want this object to be a
mirror" and there is quite a bit of work that you
need to do.
Basically, you need to render to a texture the scene
that is reflected as it would be seen in the mirror,
and then texture an object (a quadrilateral maybe)
with that texture.
There are many tutorials out there, so google your
question. There have been several threads in these
forums about it, so use the search engine in here.
You use split cameras. One normal to display on the monitor screen and one to display a screen the size of your mirror in your 3D world.
Anything that goes up to the mirror... it will be seen in the mirror.
11-17-2004, 11:36 AM
There exist a number of techniques to create mirrors. Some methods are good for flat mirrors and some are good for curved mirrors.
1. Flat mirrors.
create a matrix that translates the origo to the center of the mirror, flips e.g the z axis ( used as normal of mirror) and then translates back. This matrix can be used in combination with stencil buffers or a texture buffer + quad to do a flat mirror. One exiting benefit of this technique is that it is pretty straight forward to do recursive mirrors just by combining matrixes. the stencil technique allows a direct renering without copying of texture data to do recursive mirrors
2. Curved mirrors
create a surround texture in e.g a cube texture or a perhaps more complex spherical projected texture (fisheye lens) and use texture mapping techniques to let the normals and coordinates of the geometry to select texture coordinates in the texture. Needs multple passes to create mirror texture but adds the benefit to do curved mirrors
these techniques can also be used for refractions in e.g. glass or water, portals etc so it is pretty exiting to dig into the various techniques..
I have made a 15 lines code demo that creates recursive mirrors with my engine and you can find the example named "mirror" in the download section at www.gizmosdk.se (http://www.gizmosdk.se) This illustrates a high level of mirror usage.
Just posted this to help a guy trying to de reflections:
I think taht I also read something about the astencil buffer for reflections.... Search around... Try google for "opengl stencil buffer reflections" or somthing like that... Hope This Helps... Hope This Helps...
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.