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.
  2. Dismiss Notice

I need help with making 2 custom shaders work with URP 7.3.1

Discussion in 'Universal Render Pipeline' started by Beast32704, Aug 22, 2020.

  1. Beast32704

    Beast32704

    Joined:
    Jan 11, 2020
    Posts:
    1
    I have 2 Custom shaders that aren't made for URP and I just want to know how to make them compatible with URP.
    Code (Shader):
    1. Shader "Custom/TerrainShader"
    2. {
    3.     Properties{
    4.         _Color("Color", Color) = (1,1,1,1)
    5.         _MainTex("Albedo (RGB)", 2D) = "white" {}
    6.         _Glossiness("Smoothness", Range(0,1)) = 0.5
    7.         _Metallic("Metallic", Range(0,1)) = 0.0
    8.     }
    9.     SubShader{
    10.         Tags{ "RenderType" = "Opaque"}
    11.         LOD 200
    12.         Blend SrcAlpha OneMinusSrcAlpha
    13.  
    14.         CGPROGRAM
    15.         #pragma surface surf Standard fullforwardshadows addshadow
    16.         #pragma target 3.0
    17.  
    18.         sampler2D _MainTex;
    19.  
    20.         struct Input {
    21.             float2 uv_MainTex;
    22.             float4 color : Color;
    23.         };
    24.  
    25.         half   _Glossiness;
    26.         half   _Metallic;
    27.         fixed4 _Color;
    28.         half   _Alpha;
    29.  
    30.         void surf(Input IN, inout SurfaceOutputStandard o)
    31.         {                      
    32.             fixed4 c = IN.color;
    33.  
    34.             o.Albedo     = c;
    35.             o.Metallic   = _Metallic;
    36.             o.Smoothness = _Glossiness;
    37.         }
    38.         ENDCG
    39.         }
    40.         FallBack "Diffuse"
    41. }
    Heres my second one
    Code (Shader):
    1. Shader "Custom/WaterShader"
    2. {
    3.     Properties{
    4.         _Color("Color", Color) = (1,1,1,1)
    5.         _MainTex("Albedo (RGB)", 2D) = "white" {}
    6.         _Glossiness("Smoothness", Range(0,1)) = 0.5
    7.         _Metallic("Metallic", Range(0,1)) = 0.0
    8.     }
    9.     SubShader{
    10.         Tags {"Queue" = "Transparent" "RenderType"="Transparent" }
    11.         LOD 200
    12.         Blend SrcAlpha OneMinusSrcAlpha
    13.  
    14.         CGPROGRAM
    15.         #pragma surface surf Standard  fullforwardshadows alpha:fade
    16.         #pragma target 3.0
    17.  
    18.         sampler2D _MainTex;
    19.  
    20.         struct Input {
    21.             float2 uv_MainTex;
    22.             float4 color : Color;
    23.         };
    24.  
    25.         half   _Glossiness;
    26.         half   _Metallic;
    27.         fixed4 _Color;
    28.         half   _Alpha;
    29.  
    30.         void surf(Input IN, inout SurfaceOutputStandard o)
    31.         {                      
    32.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    33.             o.Albedo = c.rgb;
    34.             o.Metallic = _Metallic;
    35.             o.Smoothness = _Glossiness;
    36.             o.Alpha = c.a;
    37.         }
    38.         ENDCG
    39.         }
    40.         FallBack "Standard"
    41. }
     
  2. Simon_E_Sorensen

    Simon_E_Sorensen

    Unity Technologies

    Joined:
    Feb 4, 2020
    Posts:
    10
    Hi Beast32704,
    As you probably figured out, URP doesn't support Surface shaders.
    I would suggest you familiarize yourself with Shader Graph.
    For instance, here is the second one(Water) you posted, recreated with Shader Graph(note: surface is set to Transparent).
    You can dive deeper into Shader Graph here: https://unity.com/shader-graph
    Unity_Twgn28KLwb.png
    The first one you posted is just a simplified version that uses vertex colors for Albedo.
    Hope this helps!
     

    Attached Files:

  3. FartBoy79

    FartBoy79

    Joined:
    Jul 7, 2022
    Posts:
    1