David's Blog

Mostly Hobby Stuff

Reflectors

leave a comment »

Recently I added support for reflectors, i.e. mirrors, refraction maps etc. You might say that is not very impressive, granted it is quite simple to add such support to a demo app, but when you add this to a larger engine it can be quite involved. Below I will list the changes I had to make in order to support this (and future similar functionality, for example cube maps in addition to planar reflectors).

  • Add a framework of abstract base classes and collections for reflectors and reflector instances. A Reflector belongs to a model and contains most settings, a ReflectorInstance belongs to a model instance and contains instance specific data(e.g. an instance transform).
  • Add content processor support for converting (portable) reflector content into the runtime format.
  • Add editor support, including the command sequences to create reflectors(e.g. select two points which form the corners of the reflector), drawing, selection, serialization, plugin support for multiple types of reflectors etc.
  • A small amount of refactoring of the system for selecting render targets and render target textures during rendering. Plus control of which render passes are used during reflector rendering. For example particles, decals etc are rendered into reflectors. Ambient occlusion is not rendered in reflections(wouldn’t be difficult to add, but it seems kind of expensive).
  • Improve the method used to bind texture maps to materials. i.e. a new content and runtime abstract type TextureBinding(and TextureBindingContent). These allow arbitrary sources to be added for textures. Plus I added a new material node, which represents a dynamic texture from reflectors(and other sources with similar semantics).
  • Support for occlusion culling of the reflector, by implementing IRenderProxyItem. With this reflectors are only rendered when the front surface of the reflector is visible.
  • Make the cascaded shadow map code aware of reflectors so it can extend the furthest cascade to encompass the reflector view frustum. Otherwise directional lights loose shadows when the viewer can see reflections behind the camera.

Even with these changes there are still a few issues or desirable enhancements:

  • In some cases it is probably not desirable to disable cloth and particle animation when the systems are not visible by the viewer, but still visible in a reflector.
  • Render target format control + multi sampling control. At present reflectors are rendered into a RGBA float16 render target without multi-sampling. This is likely too expensive for some uses.
  • Support additional modes of operation, for example rendering refraction maps and cameras(for example a security camera which display on a monitor).
  • Support for additional reflector types, for example cube maps.
  • More control of the data rendered into the reflector, for example I could output just emissive/ambient/etc light information to the reflector.
  • etc etc 🙂

feb21_1
The above screen shot shows the CSM cascades for a view position with the viewer looking into the reflector from a small distance(the shadow and reflector updates where disabled prior to moving the player).

feb21_2
This screen shot show a close up of the reflector with the player shooting the mirror surface, note the decal on the mirror and the reflected particle system.

Advertisements

Written by therealdblack

April 10, 2010 at 5:10 pm

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: