Rasagar/Library/PackageCache/com.unity.render-pipelines.high-definition/Documentation~/custom-post-processing-create-apply.md
2024-08-26 23:07:20 +03:00

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:

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:

  1. Go to Edit > Project Settings > Graphics > Pipeline Specific Settings > HDRP.
  2. Scroll down until you find the Custom Post Process Orders section. This section contains a list for each injection point.
  3. In the After Post Process field, select Add (+).
  4. 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:

  1. Create a Volume component (Menu: GameObject > Volume).
  2. Select the Volume in the Hierarchy menu.
  3. 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.
  4. In the Inspector, select Add Override.
  5. 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:

  1. Go to Edit > Project Settings > Graphics > Pipeline Specific Settings > HDRP.
  2. Scroll down until you find the Custom Post Process Orders section. This section contains a field for each injection point.
  3. 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.