You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-22Lines changed: 32 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Customizable Post-processing Stack for Universal Render Pipeline
2
2
3
-
This package adds the ability to create custom post-processing effects for the universal render pipeline in a manner similar to [PPSv2](https://github.com/Unity-Technologies/PostProcessing) and [HDRP's Custom Post Process](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@8.2/manual/Custom-Post-Process.html). It is supposed to be a replacement for Unity's **PPSv2** till URP internally supports custom post-processing effect.
3
+
This package adds the ability to create custom post-processing effects for the universal render pipeline in a manner similar to [PPSv2](https://github.com/Unity-Technologies/PostProcessing) and [HDRP's Custom Post Process](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@8.2/manual/Custom-Post-Process.html). It is supposed to be a replacement for Unity's **PPSv2** till URP internally supports custom post-processing effects.
4
4
5
-
**Note:** You can add you custom effects in URP by inheriting from the `ScriptableRendererFeature` and `ScriptableRenderPass` classes. I personally find this to be hassle and that is why I wrote this package merely for convenience. I also took it as a chance to pick up the features I like from every post-processing solution I used for unity.
5
+
**Note:** You can already add you custom effects to URP by inheriting from the `ScriptableRendererFeature` and `ScriptableRenderPass` classes. I personally find this to be a hassle and that is why I wrote this package merely for convenience. I also took it as a chance to pick up the features I like from every post-processing solution I used in Unity.
6
6
7
7
## System Requirements
8
8
@@ -11,18 +11,20 @@ This package adds the ability to create custom post-processing effects for the u
11
11
12
12
## Features
13
13
14
-
* Conveniently add custom post processing effects similar to [PPSv2](https://github.com/Unity-Technologies/PostProcessing) (at least more convenient that writing a renderer feature and a render pass).
14
+
* Conveniently add custom post processing effects similar to [PPSv2](https://github.com/Unity-Technologies/PostProcessing) (at least more convenient that writing a renderer feature and a render pass for every effect).
15
15
* Reorder effects from the editor similar to HDRP's [Custom Post Process Orders Settings](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@8.2/manual/Custom-Post-Process.html#effect-ordering).
16
-
* Use legacy image effect shaders and unlit shader graphs if you wish (To be honest I didn't do anything, it worked out of the box so I added it to features list).
17
-
* Use `SceneNormals` feature (adapted from [Outline Study](https://github.com/chrisloop/outlinestudy) by [Christopher Sims](https://github.com/chrisloop)) to grab the scene normals on a texture.
16
+
* Use legacy image effect shaders and unlit shader graphs if you wish (To be honest I didn't do anything, it worked out of the box so I added it to the features list).
17
+
* Use it with Camera Stacking.
18
+
* Use the `SceneNormals` feature (adapted from [Outline Study](https://github.com/chrisloop/outlinestudy) by [Christopher Sims](https://github.com/chrisloop)) to grab the scene normals onto a texture.
18
19
19
20
Features that are almost untested:
20
-
* Compatible with MultiPass XR but it is tested with Mock HMD Loader only so I can't guarantee that it works on an actual headset.
21
+
* It should be compatible with MultiPass XR but it is tested with Mock HMD Loader only so I can't guarantee that it works on an actual headset.
22
+
* 2D renderers don't support renderer features yet. However, you can use camera stacking and stack a camera with a forward renderer on top of the camera with the 2D renderer. The forward renderer will apply the post processing to the result of the 2D renderer. I tried it and it worked but I didn't heavily test it yet.
21
23
22
24
## Known Issues
23
25
24
-
* It failed to work with Single-Pass Instanced Stereo Rendering. Actually, URP didn't work for me in this mode so I don't the reason behind this issue.
25
-
* The `SceneNormals` renderer feature uses the override material in the draw settings. This means that it doesn't not copy the parameters of the original material such as normal maps and alpha clipping. This should be solved in URP 10.0 with the release of the `DepthNormalsPass` made for the SSAO feature.
26
+
* It failed to work with Single-Pass Instanced Stereo Rendering. Actually, all of URP didn't work for me in this mode so I don't the reason behind this issue.
27
+
* The `SceneNormals` renderer feature uses the override material in the drawing settings. This means that it does not copy the parameters of the original material such as normal maps and alpha clipping. This should be solved in URP 10.0 with the release of the `DepthNormalsPass` made for the SSAO feature.
26
28
27
29
## Screenshots
28
30
@@ -49,13 +51,13 @@ Other custom effects in samples but not used in screenshots:
49
51
50
52
## How To Install
51
53
52
-
Follow the instructions from the Unity manual on [Installing from a Git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html) and insert the url: https://github.com/yahiaetman/urp-custom-pps.git then wait for the package to be downloaded and installed.
54
+
Follow the instructions from the Unity manual on [Installing from a Git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html) and insert the url: https://github.com/yahiaetman/urp-custom-pps.git then wait for the package to be downloaded and installed into the project.
53
55
54
-
The package contains 8 example effect which are included as a sample. Samples can be imported from the package page in the package manager.
56
+
The package contains 8 example effects which are included as a sample. Samples can be imported from the package page in the package manager.
55
57
56
58
## Tutorial
57
59
58
-
First, we need a c# shader and a script for our custom effect. We will create a grayscale effect for the sake of simplicity.
60
+
First, we need a shader and a c# script for our custom effect. We will create a grayscale effect for the sake of simplicity.
59
61
60
62
First, lets create the C# script. We will call it `GrayScaleEffect.cs`. The name of the file must match the volume component class name to comply with Unity Serialization rules. In the file write the following:
61
63
@@ -129,15 +131,19 @@ public class GrayscaleEffectRenderer : CustomPostProcessRenderer
129
131
}
130
132
```
131
133
132
-
As you can see, the code consists of two classes: the volume component and the renderer. The volume component only holds data and will appear as a volume profile option. The renderer is rensponsible for rendering the effect and read the effect parameters from the volume component. The volume component and renderer is decoupled from each other which opens up many options while implementing your effects. For example:
133
-
1. You can have a one-to-one relationship between your volume component and renderer (as we did above).
134
-
2. You can have a renderer without any corresponding volume component if it does not need any data from the volumes.
134
+
As you can see, the code consists of two classes: **a volume component** and **a renderer**.
135
+
* The volume component only holds data and will appear as a volume profile option.
136
+
* The renderer is rensponsible for rendering the effect and reads the effect parameters from the volume component.
137
+
138
+
**Volume components** and **Renderers** are decoupled from each other which presents many possibilities while implementing your effects. For example:
139
+
1. You can have a one-to-one relationship between your volume component and your renderer (as we did above).
140
+
2. You can have a renderer without any corresponding volume components if it does not need any data from the volumes.
135
141
3. You can have a renderer that reads from multiple volume components (see [GrayAndInvertEffect.cs](Samples~/Examples/Scripts/PostProcessing/GrayAndInvertEffect.cs) as an example).
136
142
4. You can have multiple renderers read from the same volume component(s).
137
143
138
-
The option#3 is especially useful for writing uber effect shaders that can do multiple effects in the same blit to enhance performance.
144
+
Option#3 is especially useful for writing uber effect shaders that can do multiple effects in the same blit to enhance performance.
139
145
140
-
Then we create the shader code. Create a shader file with any name you like (I prefer `GrayScale.shader`) and replace its content with the following code:
146
+
Now back to coding. We need to write the shader code. Create a shader file with any name you like (I prefer `Grayscale.shader`) and replace its content with the following code:
Since vertex shaders rarely contain any logic specific to the effect, we use a default vertex shader `FullScreenTrianglePostProcessVertexProgram` which is included in `Packages/com.yetman.render-pipelines.universal.postprocess/ShaderLibrary/Core.hlsl`. The fragment shader is the one reponsible for reading the original pixel color, calculating the grayscale color and blending the two colors together.
188
+
Since vertex shaders rarely contain any logic specific to the effect, we use a default vertex shader `FullScreenTrianglePostProcessVertexProgram` which is included in:
The fragment shader is the one reponsible for reading the original pixel color, calculating the grayscale color and blending the two colors together.
183
193
184
-
Now that we have our custom effect, we need to add a `CustomPostProcess` renderer feature to the foward renderer as seen in the next image. You can also add a `SceneNormals` renderer feature if you want to use scene normals in an effect (such as Edge Detection).
194
+
Now that we have our custom effect, we need to add a `CustomPostProcess` renderer feature to the `ForwardRenderer` asset as seen in the next image. You can also add a `SceneNormals` renderer feature if you want to use scene normals in an effect (such as Edge Detection).
The `CustomPostProcess` renderer feature contains 3 lists that represent 3 injection points in the `ScriptableRenderer` as seen in the next image. The three injection points are:
189
199
***After Opaque and Sky** where we can apply effects before the transparent geometry is rendered.
190
-
***Before Post Process** which happens after the transparent geometry is rendered and before the builtin post processing is applied.
200
+
***Before Post Process** which happens after the transparent geometry is rendered but before the builtin post processing is applied.
191
201
***After Post Process** which happens at the very end before the result is blit to the camera target.
192
202
193
-
The ordering of the effects in a list is the same order in which they are executed (from top to bottom). You can re-order the effects as you see fit. **Note** that the effect must be added to the renderer feature to be rendered, otherwise, it will be ignored. So we added `GrayScale` to its list `After Post Process`.
203
+
The ordering of the effects in a list is the same order in which they are executed (from top to bottom). You can re-order the effects as you see fit. **Note**: Any effect must be added to the renderer feature to be rendered, otherwise, it will be ignored. So we added `GrayScale` to its list `After Post Process`.
194
204
195
205

196
206
197
-
Then we will create a volume in the scene (or use an existing volume) and add a `GrayScale Effect` volume component to it as seen in the next image.
207
+
Then we will create a volume in the scene (or use an existing volume) and add a `Grayscale Effect` volume component to it as seen in the next image.
198
208
199
-

209
+

200
210
201
211
Now you can override the `Blend` parameter and see the view becoming grayscale.
0 commit comments