Scene Color Node in 2D renderer (URP) in ShaderGraph doesn't work--any workaround?

From what I’ve found so far, the Scene Color Node is incompatible with the 2D renderer. (It would be neat if this could be changed in a new version!)

In the meantime, does anyone know of any workarounds to get the camera texture? I’m hoping to create distortion effects.

Thanks for any leads!

The Scene Color Node does not work because it uses the _CameraOpaqueTexture. Since the 2D Renderer does not generate an opaque texture - and transparent sprites do not write to that texture - it’s not going to work.

You probably want to use the _CameraSortingLayerTexture. You can find a demo of it here:

In Shader Graph declare a new Texture2D property, make sure its reference is _CameraSortingLayerTexture, and UNCHECK Exposed. This tells ShaderGraph to get the global texture by that name.

Set up your 2D Renderer Data asset to generate the _CameraSortingLayerTexture.

The sprite that makes use of that Shader Graph must be set to render AFTER the _CameraSortingLayerTexture is created (set it to a later Sorting Layer) or else you’ll get the last frame’s colors which will look very odd.

10 Likes

Amazing, this is exactly what I was looking for. Thanks so much.

Awesome! I was looking for this too! Now I just need to figure out how to scale and offset so the sprite I apply my shader graph to lines up and scales to the background.

Dude, Thank you so much I have been looking for this for like a week. This is exactly what I wanted !