Hi! I started using the URP for the 2D lights package and it’s been really enjoyable so far. However, I’m unable to make a screen-space distortion effect (which utilizes a custom shader on a hopefully transparent object) with the 2D renderer that’s necessary to use if you want the 2D lights & shadows. I want to know if it’s possible, which it really seems like it should be, but I can’t figure it out.
My main question is, how do I mark an object as transparent for the 2D renderer in URP?
I’m able to get the screen-space distortion effect with a Forward Renderer instead by following this tutorial. With a Forward Renderer you can make a new layer and then specify that layer to render after the others inside the “Render Features” settings, which doesn’t appear to exist with a 2D renderer. But the problem with using a Forward Renderer is that 2D lights & shadows don’t work anymore.
As a different workaround for getting the same effect while using the 2D renderer, I’ve also tried to have the shader run directly on the camera by using this script attached to the camera, but it doesn’t seem to do anything:
public class ScreenWideEffect : MonoBehaviour
{
public Material material;
public void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, destination, material);
}
}
Here’s the shader graph I’m using, if it helps:
1 - the shader for an object I wanted to make transparent and put in the scene on top of other stuff
2 - slightly modified to take in the _CameraOpaqueTexture, so it can distort that and blit to screen
I also tried setting up both a 2d renderer and a forward renderer but I can’t seem to get the 2d renderer to render my should-be-transparent object as a big grey square. Which makes sense because I couldn’t find a setting that looked like it should tell the renderer that object is different and should be rendered afterwards.
So my questions are, in order of importance,
A) Is it possible to make a transparent object with the 2d renderer?
B) Is there some other way to get a screen space distortion effect while using a 2d renderer?
C) Alternately, is it possible to get 2D lights & shadows without using the 2d renderer?
D) What am I doing wrong with my OnRenderImage() script above, or with my multiple-renderer setup?