Search Unity

Question URP ShaderGraph versus writing URP Shaders (with lighting) by hand

Discussion in 'Graphics Dev Blitz Day 2023 - Q&A' started by bigpants, May 25, 2023.

  1. bigpants

    bigpants

    Joined:
    Dec 9, 2009
    Posts:
    49
    We're using Unity 2021.3.12f LTS and will be upgrading to 2022.x LTS when its available.

    Based on my small URP experience, it appears that writing URP shaders (with lighting) by hand is no longer feasible. aka. It's to complicated. Would that be an accurate assessment? As Unity progresses, will writing shaders without ShaderGraph be discouraged?

    Additionally, I'm assuming that creating your own Scriptable Render Pipeline is not a good idea these days. My main concern in creating our own SRP is that we'll be upgrading to newer versions of Unity, and a custom SRP is likely not going to upgrade nicely. My observation is based on the fact Unity versions are tightly coupled with URP versions, implying even Unity struggles to upgrade their URP pipeline. Or am I being paranoid and customers creating their own SRP are typically able to upgrade without many problems. Worth noting we're using VR.
     
  2. dnach

    dnach

    Unity Technologies

    Joined:
    Mar 9, 2022
    Posts:
    89
    Hey,

    Regarding the first question, we are planning to introduce a new streamlined workflow for text based shader authoring, called "Block Shaders". This feature will provide functionality similar to the Built-In Render Pipeline's Surface Shaders for the SRPs, allowing you to implement a lit shader's surface interface without the need and complexity of modifying the original shader source. Beyond surface shader authoring, additional public interfaces may be exposed by Unity's shader templates, allowing you to inject your own code and extend other functionalities of the source shader in a simpler and reliable manner. If there are particular shader functionalities and interfaces you are interested in implementing in such manner, please let us know!

    You can read about this more in the official announcement thread, where you can find some basic example and a very early prototype: https://forum.unity.com/threads/blo...s-and-more-public-demo-now-available.1350497/
     
    Last edited: May 26, 2023
    mandisaw likes this.
  3. ali_mohebali

    ali_mohebali

    Unity Technologies

    Joined:
    Apr 8, 2020
    Posts:
    119
    Our suggestion is that avoid writing handwritten HLSL shaders if Shader Graph can do the job for you. There are many benefits, including having friendly workflow for your artists in the team so they can also make adjustments when they need.

    Having said that, Shader Graph has its limitation and also many developers prefer handwritten shaders over graph based tools due to ease of development, maintenance etc. We are not discouraging users from writing HLSL shaders or using URP standard ones as a base to start and modify. But like you mention, it requires a bit more expertise and also comes with a cost of maintenance for your project when upgrading. HLSL shaders are not really designed to define a public/private API contract. So as we make improvements, we might break your modifications. Another factor here is that HLSL shaders are not documented yet so it requires understanding the shaders and were to modify. However, there are a lot of projects we have seen that have successfully managed this and can absorb the cost of maintenance in favour of customisability. And FYI, Block Shaders is meant to address implications with HLSL shaders and the work is in progress.

    On the topic of Custom SRP (as completely building one from scratch), there are very very few customers who do this and they have graphics engineers onboard. It's a flexibility that is available for users and is one of the big advantages of SRPs. But it's complex, requires expertise and dedication to maintenance. If you do really need to customise your pipeline, our recommendation is to start with URP/HDRP base and not from scratch. And URP definitely is a much easier pipeline to start with and a better fit for VR as well. It does come with the cost of merging changes when upgrading and we do have a lot of games made and shipped with URP/HDRP that have some level of customisability in the source. It's a question of whether it's worth the effort for the result you are after and whether you can absorb the cost of maintaining a custom URP/HDRP. Also depends on the type and amount of changes you make to the pipeline. Simple changes can be very easy to maintain and merge. So your mileage may vary.
     
    Last edited: May 25, 2023
    mandisaw likes this.