I have tried to use my own lighting model in surface shader in Unity. But there is a problem.

If I init my own lighting via

#pragma surface surf _SimpleSpecular

Lighting_SimpleSpecular method is executed. But, even if I return single color from it, my model has still applied texture (with the tint of my returned color). What I am doing wrong? I am using forward rendering.

If I switch to Standard and return single color, all is at it should be.


1 Answer 1


How is your surf defined? In addition to lighting shader, you must modify it for material properties. Here's a modified example that uses red color instead of texture from http://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html

Shader "Custom/CustomLight" {
        Properties {
            _MainTex ("Texture", 2D) = "white" {}
        SubShader {
        Tags { "RenderType" = "Opaque" }
          #pragma surface surf SimpleLambert

          half4 LightingSimpleLambert (SurfaceOutput s, half3 lightDir, half atten) {
              half NdotL = dot (s.Normal, lightDir);
              half4 c;
              c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten);
              c.a = s.Alpha;
              return c;

        struct Input {
            float2 uv_MainTex;

        sampler2D _MainTex;

        void surf (Input IN, inout SurfaceOutput o) {
            o.Albedo = float3(1,0,0);
        Fallback "Diffuse"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .