3.8 KiB
Create and apply a custom post-processing effect
Create a custom post-processing effect
A custom post-processing effect requires the following files:
- A C# Custom Post Process Volume.
- An associated full-screen shader. You can use a shader file or a Fullscreen Shader Graph.
HDRP includes a template of each file you need to set up custom post-processing. To generate each template:
- C# Custom Post Process Volume: Go to Assets > Create > Rendering and select HDRP C# Post Process Volume.
- Full-screen shader:
- To create a shader file, go to Assets > Create > Shader and select HDRP Post Process.
- To create a Fullscreen Shader Graph, go to Assets > Create > Shader Graph > HDRP and select Fullscreen Shader Graph.
Note that the file name of both the C# post-process volume and the shader need to be the same to work without any modification. If the name doesn't match, you need to update the kShaderName property to reflect the actual name of the shader.
This creates each template file in the Project window in the Assets folder.
Apply a custom post-processing effect
For HDRP to recognize a custom post-processing effect in your project, assign it in HDRP graphics settings:
- Go to Edit > Project Settings > Graphics > Pipeline Specific Settings > HDRP.
- Scroll down until you find the Custom Post Process Orders section. This section contains a list for each injection point.
- In the After Post Process field, select Add (+).
- Select the name of the custom post-processing you want to apply.
This also allows you to control the execution order of the post-processing effects in your scene. For more information, see Order custom post-processing effects.
To apply a custom post-processing effect in your scene, set up a volume component:
- Create a Volume component (Menu: GameObject > Volume).
- Select the Volume in the Hierarchy menu.
- In the Profile field, select the volume profile picker (circle) to add an existing volume profile, or select New to create a new volume profile.
- In the Inspector, select Add Override.
- In the dropdown, search for the name of the Custom Post Process Volume script and select it.
For a full script example you can use, see Custom post-processing example scripts.
Order custom post-processing effects
HDRP allows you to customize the order of your custom post-processing effects at each stage in the rendering process. These stages are called injection points.
To determine the injection points in which your effect can appear, change the enum in the following line in the C# Custom Post Process Volume:
public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess;
For more information on which enums you can use, see CustomPostProcessInjectionPoint.
To order your custom post-processing effects:
- Go to Edit > Project Settings > Graphics > Pipeline Specific Settings > HDRP.
- Scroll down until you find the Custom Post Process Orders section. This section contains a field for each injection point.
- Select the Add (+) icon to add an effect to an injection point field.
To change the order HDRP executes multiple post-processing effects within an injection point, move them up or down in this list. HDRP executes the effects in order from top to bottom.