Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feature Request Modularize URP shaders

Discussion in 'Universal Render Pipeline' started by CaffeinatedCoolaid, May 14, 2021.

  1. CaffeinatedCoolaid


    May 10, 2021
    I spent the last few weeks messing around with custom lighting shaders and got fed up with not being able to get them to look how I wanted so.. I decided to modify the main Lit shader itself, this proved to work extremely well!

    Default Lit Shader:
    Modified Lit Shader:

    But this was a tedious process with how the packages work right now and got me thinking.
    Since the shaders are already abstracted quite a bit, why don't you abstract them one level further and make all the passes separate files that can be swapped out and let the Render Pipeline generate the main shaders instead? What I'm thinking is a menu that lets you swap out the passes with custom ones like how BuiltIn lets you replace default shaders.

    Mock up:

    With something like this all I would have to do to make a copy of the ForwardLit pass include, make my modification then set it to use that file instead and regenerate the shaders. Now my custom lighting would apply all through out my project and work with any ShaderGraph shaders or assets from the AssetStore that use ForwardLit pass, easy peasy!

    This would also open up things for asset store dev's to make some really cool and integrated features!
    For instance, the fog setting in the mockup would allow the default Fog calculations to be replaced.
    Someone developing some sort of super cool VolumetricSkyandFog asset could make a
    custom render pass to render the sky, then make a custom fog function to sample it and do the magic.
    Installing the asset would be just as simple as adding the custom render feature and replacing the default Fog include with the custom supplied one. The asset would then be fully integrated into Unity and just work.

    Another simple example. You could add extra passes into the shader then use RenderObjectsFeature to call the pass essentially recreating replacement shader (Which we desperately need).

    I think this would be pretty trivial to implement but would give some huge wins in the graphics and asset development department!
    Lo-renzo and PutridEx like this.