Camera Rendering in LWRP

No support for Camera Stacking in LWRP.

What: Camera stacking is when a camera depends on the results of a previous one. In built-in render pipeline users achieve camera stacking by configuring a first camera with skybox or color clear. Then setup a second camera with DepthOnly or DontClear flags and expect the render target of the second camera will be initialized with the color contents of the first.

Camera stacking can also be achieved by using Canvas Renderer Screen Space – Camera mode.

Why: Stacking has many problems. 

  • It has many corner cases to do it properly. Cameras might have different viewports, different render target descriptors (HDR, MSAA). This has been a source of many bugs and pain in Built-in Unity.  

  • By not supporting camera stacking we guide users towards a more performance oriented workflow.

    • Less state changes

    • Less bandwidth cost

    • Less time spent doing culling

Proposition:

LWRP renders camera independently from each other. The first render pass of every camera will not do any tile LOAD operation or readback. The camera either render directly to back buffer or to a render texture and then blit to backbuffer.

Each camera renders as follows:

  1. If camera can render straight to backbuffer

  1. If camera can’t render directly to backbuffer

The temporary texture is pooled based on the RenderTexture descriptor. It’s scaled by the camera viewport and render scale feature if in monoscopic rendering. Viewport and render scale is controlled by XR framework if stereo is enabled.

In order to implement this workflow we need to remove the Camera Clear Flags, instead users should configure how the camera target is initialized for the first render pass. 

Camera Clear Flags is replaced with Background Type

First render pass to the camera never do tile LOAD or readback:

Background Type

Color LOAD Action

Depth LOAD Action

Skybox

DONT_CARE

CLEAR

Solid Color

CLEAR

CLEAR

Don’t Care* (New)

DONT_CARE

CLEAR

* Don’t Care is provided as a performance hint. It should be used when the user know the camera will render to all pixels in the render target. Don’t Initialize does not have any effect on mobile.

Additional render passes always do LOAD for all render pass output.

How does Clear Flags upgrade from Built-in

Built-in Clear Flags

LWRP Background Type

Skybox

Skybox

Solid Color

Solid Color

Depth Only

Solid Color

Don’t Clear

Don’t Initialize

        

How does UI work in LWRP

Currently Screen Space – Camera mode is the only mode not working. It will be supported in 19.1 

How to render geometry that requires special camera setup

Users need to create a ScriptableRenderPass and inject in LWRP code to render things that require different camera matrices/fov. These vary on a case by case scenario, f.ex, rendering weapons in an FPS.

Post-Processing

Post-Processing is not applied globally to screen. It’s applied instead to each camera render. 

Leave a Comment

Your email address will not be published. Required fields are marked *