Visual Compositor Overview
Introduction
Visual Compositor provides a node based graph editor to do image compositing.
The graph is used to construct rendering sources and flow, in order to output layers,
which are then stacked together using blending options to produce the final image.
Dependencies
Selection Groups
Used to group GameObjects and render particular groups.
This allows for more flexibility than the
layer system, which is limited to 31 unique layers.
Please see the
user documentation
for more details on Selection Groups.
Streaming Image Sequence
Used to play sequential image sequences in order to apply post-processing on them.
Timeline
Used to animate the parameters of Visual Compositor nodes.
Supported Unity Versions and Settings
Visual Compositor supports:
- Unity
2020.3.45
or higher. - Unity
2021.3.19
or higher. - Unity
2022.2.8
or higher.
on Built-in, Universal, and High Definition render pipelines with either linear (recommended) or gamma workflow.
Using Visual Compositor on High Definition Render Pipeline (HDRP) requires HDRP assets to use R16G16B16A16 color buffer format.
Please refer to the installation page to install VisualCompositor package.
Quick Start
This figure shows the scene that we will use for this guide.
Note the Selection Groups window, and the created groups for the shapes, ground and lights.Create an empty GameObject, and add the Visual Compositor component.
Scroll down to the bottom of the Visual Compositor component and click the "New" button to automatically create a Compositor Graph asset and set it up. This asset stores the graph that we will construct in the following steps.
Open Window > Rendering > Visual Compositor.
As this window uses a lot of screen area, we recommend to dock this window behind the scene view.By default, the output of Visual Compositor will be displayed in Display 8.
We can set the existing Game view to show Display 8, or add a new Game view in the Editor to view the output.
See more details in the camera section below.When we select the VisualCompositor GameObject created in step 3, the Visual Compositor window will load the graph in that component, and will automatically create default nodes for newly created graphs.
See the Visual Compositor window documentation for more details on using this window.Make sure that the graph is built as shown in the following figure.
Using Selection Group nodes in combination with Render nodes allow us to render specific objects with specific lights.
In the next figure, there are three Selection Group nodes, with a Union node being used to combine two groups into one group.Add a Drawn Edges node for extracting edges from the Render node, and a Layer node for compositing over the first layer.
Please refer to the next figure for node setting details.- Connect the outputs of the Render node to the corresponding inputs of the Drawn Edges node.
- Connect the output of the Drawn Edges node to the input of the new Layer node, and set the blend mode is multiply.
The final image is now a composite of the two layers.
Camera
Visual Compositor is using a Camera
to define where to render its final output via the Target Display property of the Camera.
This Camera component is automatically added whenever we add Visual Compositor
to a GameObject, and it must be different from the Camera that we use to render objects.
The following Camera properties are automatically setup by Visual Compositor, and we need to ensure that their values are kept as they are.
Properties | Reasons of overriding the values |
---|---|
Clear Flags | Visual Compositor produces the final render output by executing the Compositor Graph asset, and does not require the Camera's rendering process. |
Culling Mask | Visual Compositor produces the final render output by executing the Compositor Graph asset, and does not require the Camera's rendering process. |
Other Camera properties are ignored.