URP Grab Pass
ๆฅๆฌ่ชใใญใฅใกใณใ(Japanese Documents Available)
Replacement for GrabPass in Unity's Universal Render Pipeline (URP).
Features
- You can get the camera's color texture at the following timings.
- After drawing opaque objects
- After drawing transparent objects
- Then you can use it in your shader.
- In contrast to URP's _CameraOpaqueTexture, you can also get the color texture after drawing semi-transparent objects.
Requirement
Universal RP 10.2.0 or higher.
Unity2020.2.3f1 or higher.
VR is not supported.
Usage
Setup Universal Render Pipeline
- Follow the manual below to set up the URP.
- https://docs.unity3d.com/Packages/[email protected]/manual/InstallingAndConfiguringURP.html
Install URP Grab Pass
- Open the Package Manager from Window > Package Manager
- "+" button > Add package from git URL
- Enter the following
Or, open Packages/manifest.json and add the following to the dependencies block.
{
"dependencies": {
"com.harumak.urpgrabpass": "https://github.com/Haruma-K/URPGrabPass.git?path=/Assets/URPGrabPass"
}
}
If you want to set the target version, specify it like follow.
Setup Renderer Feature
- Add the Grab Pass Renderer Feature from the inspector of the Forward Renderer Data.
- Change the properties of the Renderer Feature if necessary.
Property Name | Description |
---|---|
Name | Name of the Renderer Feature. |
Timing | When to get and use the camera's color texture. |
Grabbed Texture Name | Name of the grabbed texture when it is used in the shader. |
Shader Light Modes | LightModes for shaders that use the texture. |
Sorting Criteria | How to sort objects during rendering. |
Write and use the shader
- Write the shader that uses the texture.
- The shader must have the LightMode specified in the Renderer Feature.
- You can get the texture by the name specified in the Renderer Feature.
- Sample: https://github.com/Haruma-K/URPGrabPass/blob/master/Assets/Demo/Shaders/shader_demo_usegrabbedtexture.shader
- Assign this shader to the material to render it.
- Objects with this material will be rendered immediately after the texture is grabbed.
Demo
- Clone this repository.
- Open the following scene.
License
This software is released under the MIT License.
You are free to use it within the scope of the license.
However, the following copyright and license notices are required for use.