This file demonstrates one way to create a mirror effect in Panda.
setupMirror() to create a mirror in the world that reflects
everything in front of it.
The approach taken here is to create an offscreen buffer with its own camera that renders its view into a texture, which is then applied to the mirror geometry. The mirror’s camera is repositioned each frame with a task to keep it always on the opposite side of the mirror from the main camera.
This demonstrates the basic interface for offscreen render-to-a-texture in Panda. Similar approaches can be used for related effects, such as a remote spy camera presenting its view onto a closed-circuit television screen.
In this example the mirror itself is always perfectly flat–it’s just a single polygon, after all–but small distortions of the mirror surface are possible, like a funhouse mirror. However, the reflection itself is always basically planar; for more accurate convex reflections, you will need to use a sphere map or a cube map.
setupMirror(name, width, height, rootCamera=None, bufferSize=256, clearColor=None)¶