Shaders and the people who love them

Right, so, uh…

Shader "Custom/Redline" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _Ramp ("Ramp Texture", 2D) = "white" {}
        _SpecRamp ("Specular Ramp", 2D) = "white" {}
        _Outline ("Outline", Range(0,1)) = 0.4
		_OutlineColor ("Outline Color", Color) = (0,0,0,1)
        _Shininess ("Shininess", Range(0,10)) = 0.1
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
		UsePass "Toon/Basic/BASE"
		Pass {
			Name "LIGHTING"
			Tags { "LightMode" = "Always" }
			Cull Off
			ZWrite On
			ColorMask RGB
			Blend SrcAlpha OneMinusSrcAlpha
	        
			CGPROGRAM
			#pragma lighting LightingToon
		
			sampler2D _MainTex;
		    sampler2D _Ramp;
		    sampler2D _SpecRamp;
		    float _Shininess;
	        
	        half4 LightingToon(SurfaceOutput s, half3 lightDir, half atten ) {
		       		half4 c;
		            half NdotL = dot(s.Normal, lightDir);
		            NdotL = tex2D(_Ramp, float2(NdotL, 0.5));
		            
		            half NdotLSpec = dot(s.Normal, lightDir);
		            NdotLSpec = tex2D(_SpecRamp, float2(NdotLSpec, 0.5));
		 
		            c.rgb = (s.Albedo * _LightColor0.rgb * NdotL * (atten * 2)) + (NdotLSpec * _Shininess);
		            c.a = s.Alpha;
		            return c;
		        }
	        ENDCG
   		}
		UsePass "Toon/Basic Outline/OUTLINE"
    }
    FallBack "Diffuse"
}

This is meant to be a toon shader with two ramps, one for basic lighting and one for specularity. It won’t work – the entire textured surface consists of black and in fact, getting the entire thing down to this:

Shader "Custom/Redline" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _Ramp ("Ramp Texture", 2D) = "white" {}
        _SpecRamp ("Specular Ramp", 2D) = "white" {}
        _Outline ("Outline", Range(0,1)) = 0.4
	_OutlineColor ("Outline Color", Color) = (0,0,0,1)
        _Shininess ("Shininess", Range(0,10)) = 0.1
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
		UsePass "Toon/Basic/BASE"
		UsePass "Toon/Basic Outline/OUTLINE"
    }
    FallBack "Diffuse"
}

that is, a straight copy of the standard Lighted Outline shader, throws the exact same result. Is something obvious flying over my head again?

Finally solved it. Here’s the code if that interests anybody.

	Shader "Custom/Redline" {
	    Properties {
	        _MainTex ("Base (RGB)", 2D) = "white" {}
			_Color ("Color", Color) = (1,1,1,1)
	        _Ramp ("Ramp Texture", 2D) = "white" {}
	        _SpecRamp ("Specular Ramp", 2D) = "white" {}
	        _Outline ("Outline", Range(.002, 0.03)) = .03
			_OutlineColor ("Outline Color", Color) = (0,0,0,1)
	        _Shininess ("Shininess", Range(0,10)) = 0.1
	    }
	    SubShader {
	        Tags { "RenderType"="Opaque" }
	        
	    	CGPROGRAM
    		#include "UnityCG.cginc"
			#pragma surface surf Toon noambient
			
			sampler2D _MainTex;
			float4 _Color;
			sampler2D _Ramp;
			sampler2D _SpecRamp;
			float _Shininess;
			
			struct Input {
				float2 uv_MainTex : TEXCOORD0;
			};
			
			void surf (Input IN, inout SurfaceOutput o) {
				half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
				o.Albedo = c.rgb;
				o.Alpha = c.a;
			}	
			
	        half4 LightingToon (SurfaceOutput s, half3 lightDir, half atten ) {
	        
				#ifndef USING_DIRECTIONAL_LIGHT
				lightDir = normalize(lightDir);
				#endif
				
		       	half4 c;
		        half NdotL = dot(s.Normal, lightDir);
		        NdotL = tex2D(_Ramp, float2(NdotL, 0.5));
		            
		        half NdotLSpec = dot(s.Normal, lightDir);
		        NdotLSpec = tex2D(_SpecRamp, float2(NdotLSpec, 0.5));
		 
		        c.rgb = (s.Albedo * NdotL) + (NdotLSpec * _Shininess);
		        c.a = s.Alpha;
		        return c;
		    }
	    	ENDCG
			UsePass "Toon/Basic Outline/OUTLINE"
	    }
	    FallBack "Diffuse"
	}