Search Unity

Resolved Surface Shaders Not Rendering on 2D Sprites

Discussion in 'Shaders' started by RadRedPanda, Feb 1, 2021.

  1. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,648
    For some reason whatever surface shader I write for a 2D sprite just renders as the placeholder magenta color, are there any settings or other weird reasons why my surface shader won't render?

    upload_2021-2-1_14-52-33.png

    I quite literally copied the Example code from the Unity documentation and it still doesn't seem to be working at all.

    Code (CSharp):
    1.  
    2. Shader "Example/Diffuse Texture" {
    3.     Properties{
    4.       _MainTex("Texture", 2D) = "white" {}
    5.     }
    6.         SubShader{
    7.           Tags { "RenderType" = "Opaque" }
    8.           CGPROGRAM
    9.           #pragma surface surf Lambert
    10.           struct Input {
    11.               float2 uv_MainTex;
    12.           };
    13.           sampler2D _MainTex;
    14.           void surf(Input IN, inout SurfaceOutput o) {
    15.               o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
    16.           }
    17.           ENDCG
    18.     }
    19.         Fallback "Diffuse"
    20. }
    Vertex and fragment shaders seem to be working fine, but don't register lighting effects which are going to be present.
     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,648
    Looks like it was because the project I was working on was using URP, which doesn't support using Surface Shaders.