Easy mirrors on flat surfaces: more progress

Posted on

The implementation of our “easy mirrors on flat surfaces” is more-or-less complete now. I’ll be working on a documentation and better demos soon. For now, see the description below.

Features:

  • Setting up the mirror is a matter of using X3D node ViewpointMirror with RenderedTexture (to get a texture containing mirror), and applying this texture with generated coordinates by TextureCoordinateGenerator { mode "MIRROR-PLANE" }.
  • A working demo is in viewpoint_mirror.x3dv. Just get the demo-models repository and open viewpoint_mirror.x3dv inside with view3dscene from snapshots or any Castle Game Engine 3D example. A better demo will follow shortly, showing also how to use this with Blender and Pascal, without hand-crafting an X3D file.

  • Multiple mirrors work nicely and can produce recursive reflections (when a mirror is visible in a mirror). Each frame updates the mirrors based on their previous contents, so the recursion depth is practically unlimited with zero cost.

  • A mirror texture can be mixed with material and other textures using multi-texturing, just like any other texture.

  • The mirror geometry can be any complicated shape. It doesn’t have to be a simple quad! However, it should be more-or-less planar (we automatically calculate a best fit plane looking at geometry) in order to get sensible results.

  • The texture mapping TextureCoordinateGenerator is done by shaders on GPU. So it remains fast even for complicated objects. The mirror itself is rendered using FBO.

This work is sponsored by the Castle Game Engine supporters on Patreon, in particular thanks go to Robert Daniel Murphy for requesting this feature. If you like what I’m doing, please consider supporting me! Thank you.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.