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

Question Help upgrading shader to URP

Discussion in 'Shaders' started by redstoner8989, Aug 31, 2023.

  1. redstoner8989

    redstoner8989

    Joined:
    Jan 15, 2023
    Posts:
    7
    Hey. I have little to no experience with shaders, but I'm forced to work . For an upcoming game, I needed a texture that can be procedurally generated with information from vertices and colors. I have found this shader on a forum, and it worked fine until I upgraded from the Built-In render engine to the URP engine.



    Code (CSharp):
    1. Shader "PlanetShader"
    2. {
    3.     Properties
    4.     {
    5.         [HideInInspector] __dirty( "", Int ) = 1
    6.     }
    7.  
    8.     SubShader
    9.     {
    10.         Tags{ "RenderType" = "Opaque"  "Queue" = "Geometry+0" }
    11.         Cull Back
    12.         CGPROGRAM
    13.         #pragma target 3.0
    14.         #pragma surface surf Standard keepalpha addshadow fullforwardshadows
    15.         struct Input
    16.         {
    17.             float4 vertexColor : COLOR;
    18.         };
    19.  
    20.         void surf( Input i , inout SurfaceOutputStandard o )
    21.         {
    22.             o.Albedo = i.vertexColor.rgb;
    23.             o.Alpha = 1;
    24.         }
    25.  
    26.         ENDCG
    27.     }
    28.     Fallback "Diffuse"
    29.     CustomEditor "ASEMaterialInspector"
    30. }
    I would appreciate it if someone could explain to me what exactly it does, and how an upgrade to URP would look like.
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,977
    It's a standard shader that plugs the vertex colors into albedo.

    Use the Shader Graph and plug the Vertex Color Node into albedo.
     
    redstoner8989 likes this.
  3. redstoner8989

    redstoner8989

    Joined:
    Jan 15, 2023
    Posts:
    7
    upload_2023-8-31_22-25-46.png

    Is this what you mean by chance? The objects just seem to appear as black, I'm unsure if it's the generator script causing it or if it is this shader graph.
    (I couldn't find albedo, am I missing something?)
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,977
    You’re not missing something, I just keep forgetting they changed the terminology for SRP. The graph looks correct, not sure why it’s not working.
     
  5. redstoner8989

    redstoner8989

    Joined:
    Jan 15, 2023
    Posts:
    7
    Eventually got it working modifying some atmosphere settings. Thanks!