-
-
Notifications
You must be signed in to change notification settings - Fork 43
How it works
BACK > Home
This page explains how the functionality behind kMirrors works.
Data diagram for kMirrors.
Mirrors are created either manually in the Editor or at runtime via the Mirror
API.
Mirrors use the BeginCameraRendering
callback in Universal Render Pipeline. Mirrors are processed for each active Camera that is not of type Preview or Reflection.
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.
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.
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.
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.