Prepass Queue and Custom lighting

Hey!

I want to have a texture for the specular color, so I made a shader for that, but I’m having some issues…
It works fine as long as I’m in the transparent Queue, as soon as I switch to Geometry queue the lighting becomes all wrong on the model…

here’s the shader.

Shader "Characters/DNSE" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _SpecTex("Specular Texture",2D) = "black" {}
        _Shininess("Glossiness",Range(0,2)) = 1.0
        _Bump("NormalMap",2D) = "bump" {}
    }
    SubShader {
        Tags { "Queue" = "Geometry" "RenderType"="Opaque" }
        LOD 200
       
        CGPROGRAM
        #pragma surface surf Characters nolightmap nodirlightmap

        sampler2D _MainTex;
        sampler2D _Bump;
        sampler2D _SpecTex;
       
        float _Shininess;
       
        struct CustomSurfaceOutput
        {
            fixed3 Albedo;
            fixed3 Normal;
            fixed3 Emission;
            fixed3 GlossColor;
            fixed Specular;
            fixed Alpha;
        };

        struct Input {
            float2 uv_MainTex;
        };
       
       
        inline fixed4 LightingCharacters ( CustomSurfaceOutput s, fixed3 lightDir, fixed3 viewDir, fixed atten){

            half3 h = normalize (lightDir + viewDir);

            fixed NdotL = max (0, dot (s.Normal, lightDir) * 0.5 + 0.5 );
            fixed NdotH = max (0, dot (s.Normal, h));

            fixed3 spec = pow (NdotH, _Shininess*128.0);
            fixed3 specCol = spec * s.GlossColor.rgb;
           
            fixed4 c;
           
            c.rgb = (s.Albedo * _LightColor0.rgb * NdotL + _LightColor0.rgb * specCol) * (atten * 2.0);
            c.a = s.Alpha + _LightColor0.a * spec * atten;
           
            return c;

        }
       
        inline fixed4 LightingCharacters_PrePass (CustomSurfaceOutput s, half4 light)
        {
            fixed3 spec = light.a * s.GlossColor;
          
               fixed4 c;
            c.rgb = s.Albedo * light.rgb + light.rgb * spec;
            c.a = s.Alpha + spec;
            return c;
        }

        void surf (Input IN, inout CustomSurfaceOutput o) {
            fixed3 tex = tex2D (_MainTex, IN.uv_MainTex);
            fixed3 spec = tex2D (_SpecTex, IN.uv_MainTex);
            fixed3 bump = UnpackNormal(tex2D(_Bump,IN.uv_MainTex));
           
            o.Albedo = tex;
            o.Normal = bump;
            o.GlossColor = spec;

        }
        ENDCG
    }
    FallBack "Diffuse"
}

the forward pass works fine, only the deferred pass gives me this problem…

Thanks!

nice question, i want to see a specular color shader, geometry shader is DX11 only ??!? do you have a geom shader there? i see that the CG isnt specified which version i.e. dx9 / dx11 , the version config line is missing. i dunno i am abit noob.

no, that’s not a geomerty shader, just a regular sufrace shader with custom lighting model.