ScriptableRenderPass - johnsietsma/ExtendingLWRP GitHub Wiki
DRAFT
DISCLAIMER: This is not official documentation. This is a feature in preview, this documentation may get out of date quickly! See the Home page for documentation links.
The see overview of LWRP Rendering
What is a Render Pass?
A concept of a render pass in the LWRP quite a broad, but ultimately it will render something to a render target. Along the way it may also filter objects to be rendered, select shader passes to use, create and set render texture targets, set shader properties, change render settings and more.
There is also RenderPass class which can be used in a custom render pass. It sets a render target and attachments and allow you to execute SubPasses that can share attachments with the pass they are part of.
Creating a Custom Render Pass
All passes, including custom passes, are classes derived from ScriptableRenderPass
.
Because all the in-built passes are also ScriptableRenderPass
derived classes, you can have a look at the code to see some examples of how they work.
The only function you must implement is void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)
;
Adding a Custom Render Pass
Once you've derived your class, you need to tell the LWRP when you'd like that pass to execute.
The LWRP looks for components attached to a camera that implement an interface. It will then call
ScriptableRenderPass GetPassToEnqueue(
RenderTextureDescriptor baseDescriptor,
RenderTargetHandle colorAttachmentHandle,
RenderTargetHandle depthAttachmentHandle);
You return an instance of the custom pass, the LWRP will queue it and execute it at the correct stage of the render pipeline.
Render Pass Interfaces
Here is the stages where custom render passes can be scheduled:
- IAfterDepthPrePass
- IAfterOpaquePass
- IAfterOpaquePostProcess
- IAfterRender
- IAfterSkyboxPass
- IAfterTransparentPass
Examples
Please see the ExtendingLWRP github repo for examples of custom render passes.