I am trying to create big, flat ground object that reflects the objects on it, like a marble floor. I have used the technique covered in: http://www.opengl.org/resources/code/samples/mjktips/Reflect.html to achieve the effect in pure OpenGL, but as I am quite new to panda3d, I don’t know how to do it with panda3d, as the panda library handles all the rendering for me. Any pointers?
Take a look at the Nature Demo, it uses a plane reflecting the objects in the scene as you want, and deforms it based on a normal map.
The nature dÃ©mo water shader doesn’t reflect anything since 1.3.2
Here is the modified Nature Demo that works with current version of Panda:
All right belong to the author of the demo. All working code is belongs to him, all bugs are my own.
Actually it doesn’t work, at least not on my Ubuntu with panda 1.5.2. Why not convert the bam models to egg format?
Meanwhile I have been trying to get rendering the scene upside down to work. Creating a new camera and setting its scale Z to value -1 causes the scene to be rendered both normally and upside down at the same time. This technique, however, results in weird renderings as the rotation angles should also be mirrored for the other camera.
The technique referred to in the OP is much more fundamental than NatureDemo’s trick: it’s just replicating geometry underneath the floor, and using the stencil buffer to mask out the parts that you might see around the mirror. Of course, if you’re in an enclosed room and the floor covers the entire room, you don’t even need the stencil buffer. (But if you do want to exactly replicate the technique, you can use a stencil buffer by creating a StencilAttrib.)
If you want to go the draw-the-scene-twice technique, the correct way to position the camera for a mirror is via a Plane, representing the surface of the mirror, and then applying plane.getReflectionMat() (along with the composition of the plane’s transform from the scene graph) to the camera. This is demonstrated in direct/src/showbase/MirrorDemo.py.