Skip to content

How it works

Matt Dean edited this page Jan 31, 2020 · 1 revision

BACK > Home


Welcome to kMirrors!

This page explains how the functionality behind kMirrors works.

alt text Data diagram for kMirrors.

1) Creation

Mirrors are created either manually in the Editor or at runtime via the Mirror API.

1) Callbacks

Mirrors use the BeginCameraRendering callback in Universal Render Pipeline. Mirrors are processed for each active Camera that is not of type Preview or Reflection.

2) Render Texture Management

Before rendering we must test for changes in settings on the Mirror component. A RenderTextureDescriptor is generated from the component settings and tested against the previous descriptor. If the descriptor has changed the active RenderTexture is destroyed and a new one is created.

3) Matrix creation

Next we generate the matrices needed for mirror rendering. First we mirror the source camera's view matrix. Next we generate a near clip plane from the mirror's plane and use it to generate an oblique projection matrix. Finally these matrices are assigned to the reflection camera.

4) Rendering

Before rendering we set some miscellaneous camera settings, such as culling masks, HDR and MSAA. The reflection camera is rendered into the RenderTexture using the RenderSingleCamera function in Universal Render Pipeline.

5) Output

The final stage is assigning the reflection texture and settings to shaders and/or renderers. This stage is dependent on the Scope setting of the Mirror component. See Getting started - Output Options for more information.