Reflections

Last week I was doing some testing with custom render components and I ended up creating a new demo that implements a reflections. You can see the results in the next image:

Reflections

Long story short, I’m using a custom render component that creates a reflection of a given scene in four steps. The first step is to render the base plane (the one that will be used to reflect the scene) into the stencil buffer. Then, we render the reflected scene using the stencil buffer information to clip those portions of the reflection that lie outside of the base plane. The reflection illusion is created by rendering the scene upside-down.

Rendering the reflected scene

The third step is to render the actual scene. No special process is required here:

Rendering the scene on top of its reflection

The last step is to render the base plane again, this time enabling textures and lighting. In addition, we’re going to use forward-to-back blending, creating the illusion of a polished surface and producing the final effect.

The final result

The source code for this example can be found in the examples/Reflections directory. The custom render component used in this example is not as generic as I would like it to be, but it can be easily modified to suite any scene if required.

Advertisements

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