Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How to convert Custom Shaders to URP in Unity?

Discussion in 'Universal Render Pipeline' started by castana1962, May 26, 2020.

  1. castana1962

    castana1962

    Joined:
    Apr 10, 2013
    Posts:
    391
    Hi All
    Sorry but I am new in the URP topics and I have a Unity project with Custom Shaders and I need to upgrade it to URP, for it, Could anybody advice about how to do it?
    Thanks for your time
    Alejandro
     
  2. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    414
    Your old unlit shaders shouldn't need a ton of work, although you may need to remove LightMode Tags, like ForwardBase, if those snuck into your unlit shaders...

    Your lit shaders will basically be incompatible, and you will need to either recreate them in Shader Graph, for maximum portability with future versions of URP, or base new versions of them off of stock URP shaders like Lit and SimpleLit, which are included in the packages:

    upload_2020-5-26_15-36-13.png

    Then, once your shaders are working, you will want to make them SRP Batching compatible, for better performance. This is done for you if you work through Shader Graph, otherwise, you will need to read the blog and then convert your CG to HLSL with the new functions, using the Unity GitHub as a reference for the new utility HLSL function names:
    https://blogs.unity3d.com/2019/02/2...65.2114811621.1589907216-731577765.1544037663

    https://github.com/Unity-Technologi...l/ShaderLibrary/ShaderVariablesFunctions.hlsl

    https://github.com/Unity-Technologi...lines.core/ShaderLibrary/SpaceTransforms.hlsl
     
unityunity