help with deffered rendering?

Hello,

I am having trouble using deferred rending with a custom shader (it works with standard shader)

using this shader renders black. I have Deffered set in camera as well as player settings, and anti aliasing is off. what am I doing wrong?

Shader "df/deferredLambert" {
    Properties {
       
        _MainTex ("Base (RGB)", 2D) = "white" {}

    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200
       
        CGPROGRAM
        #pragma surface surf dfDeferred
   
        sampler2D _MainTex;

        struct Input {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutput o) {
            half4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }
       
        fixed4 LightingdfDeferred_PrePass (SurfaceOutput s, half4 light)
        {
            fixed4 c;
            c.rgb = s.Albedo * light.rgb;
            c.a = s.Alpha;
            return c;
        }
       
        ENDCG
       
   
    }
    FallBack "Diffuse"
}

The documentation here is incomplete. _PrePass is for the legacy deferred. For the Unity 5.0 deferred you need to use _Deferred. Also note that deferred doesn’t actually support custom lighting models; everything that is rendered deferred will use the standard shader.

1 Like

ah thank you, that’s good to know. however the material still renders black after changing to _Deferred… also i noticed something strange, when i select the model the wireframe looks like this:

(wireframe looks normal with _PrePass or no suffix)

I’m at a loss on that one lol