Add a postprocess effect on just the 2D lighting

I want to add effects on the 2D lighting using a shader but I can’t seem to get it to work.

I created a custom ScriptableRenderPass, a custom ScriptableRendererFeature and a custom VolumeComponent. I want to use my shader after the “Draw 2D Lights” pass.

When I use the frame debugger the outcome of the “Draw 2D Lights” pass looks like this:

Now I want to use my shader on this texture before it gets added back over the lit sprites.

I use RenderPassEvent to try and set the moment were my pass will be executed but it looks like it’s always exectuted either just after the clearing of the frame or after everything has been renderd. Because I see the output of my shader in the back, so even behind my backgrounds, or totally in the front of everything else so that it’s a postprocessing effect of my whole frame.

Is what I want even possible in URP 2D? The examples I’ve used were all for URP but in 3D.

I’ve got bad news: this is not possible without forking the 2D Renderer and and blitting the light textures after they’re created. This would be tricky.

The good news: you didn’t have to waste many hours reading the 2D Renderer internals to figure this out.

On the off chance that you’re wanting to blur the shadows, check out 2023.1+ where soft shadows is a feature. If that’s not your intention, forget I said anything :wink:

One more thing: if the effect is relatively simple you could maybe get away with using a Sprite Lit Custom shader graph and changing how the lighting is sampled with the Light Texture node. For instance, you could do a rudimentary blur this way, or invert the colors, or distort the UVs for something funky.

Thanks for your reply!! I was afraid of that, but that is the way it works for 3D right?

The effect I’m looking for is a pixelated light/shadow, I’m building a pixelated sidescroller and those straight lines of the lights/shadows look really out of place, with falloff it looks even weirder. I made a pixelate shadergraph which I use in more places in my game so I thought that if I could grab the final light/shadow textures I could apply my shader on that.

And as you mentioned, I indeed also want soft shadows, that’s something that’s also missing, but as you said I could switch to 2023 for that, but I got another problem with that, I’m also using the asset SuperTilemapEditor, and when I switch to 2023 lighting on those tilemaps is broken so for now that won’t work for me. And that doesn’t solve my pixelate problem either.

I also tried the pixel perfect camera component and then upscale render texture so that my whole scene is pixelated, but then all movement looks really jenky and there’s no way to fix that, I’ve been in that rabbit hole already:-)

So maybe the only way to do this is to fork the 2D Renderer, I was hoping to avoid that.