(I’ve re-posted this thread as I cannot move it, I think this is a better place for it)
I forked the Github repository of the URP and spent around 1 week, in total, to implement several features in the 2D Renderer that were required for Jailbroken to look visually acceptable. As a first step, I stopped using Shadergraph and converted all shaders to HLSL/Cg.
Multiple render targets
In order to be able to achieve some post-processing FXs, I needed 2 additional render targets to which to write for all the sprites in the scene. I modified the ScriptableRenderer, Renderer2D and Renderer2DData classes.
Now I can specify additional render targets using the inspector:
Emissive colors
This is implemented in the shaders. If the Unlit checkbox is checked, I ignore the light textures and use colors of the main texture of the sprite directly; if it’s unchecked, then I mix the main color, the light color and the colors coming from a secondary texture (chosen in the Sprite editor). The emissive color depends also on a power multiplier and a color that affects all emissive pixels.
Additionally, emissive pixels are written to the Bloom render target.
Bloom FX limited to emissive colors
One thing I didn’t like of the official implementation of the Bloom FX in Unity is that it affected everything. This may be desirable sometimes, though. I wanted that only shiny things were affected so I added another render target to write to, and passed that texture to the existing post-processing FX (PostProcessPass class), in the Renderer2D class.
Configurable alpha blending
Sometimes you need to change how colors are blended. A common case is when creating energy or fire VFX. I added this possibility to my shaders and used a custom shader inspector to display the options in a friendly way. This is a built-in feature for normal URP Shadergraph shaders, but does not exist for the 2D Renderer.
Custom post-processing FXs
I created new post-processing FXs (which is not possible with the 2D Renderer at the moment) by modifying the Renderer2D class and copying and reducing the PostProcessPass class.
For example, I used displacement maps (to simulate shockwave FXs) written when the sprites are rendered and the used that texture in a post-processing FX to calculate the colors:
Here you can see 2 of them combined (vignette with texture and distortion):
Revived Freeform lights Falloff offset in v2021
The Falloff offset feature of the 2D lights was removed in version 2021. I need it in my project so in order to be able to upgrade the editor, I revived it. If you need it, you can take the commit from here:
Light volume textures
I wanted to fake the visual effect of the light on an illusory mass of smoke. To achieve this, I modified the 2D lights (Light2D, RendererLighting and Light2DEditor classes, and the Volumetric versions of the Light2D shaders). Now I can add animated textures to the lights and combine them as needed to simulate whatever I want:
Shadow rendering optimization
Do you use ShadowCaster2Ds and want the performance of your game drastically boosted? I wanted that too.
I created a class derived from ShadowCaster2D that takes all the meshes of the ShadowCaster2Ds in the child objects and blends them together into one. Then all the ShadowCaster2Ds are disabled or destroyed. So when the shadows are to be rendered, there is only 1 draw call instead of 1 per shadow caster (which, in fact, produces many more than 1). It’s like what I would have expected from the CompositeShadowCaster2D, a way to group shadow casters.
I got a boost of +50% of performance in some cases, although it depends on the scene setup.
Here is the demonstration:
[THE LIST CONTINUES IN A POST BELOW ]
That’s all for now!
Other things I shared with the community that you may find useful: