How to make a light only emit speculars ?

Hello !

I’m trying to find a way to make so that my 3d mesh is lit only by specular light, and reflects no diffuse light at all.
I know there is an option in Maya lights to separate diffuse and specular emmision, and to disable independently one or the other one.
Is there a method to do the same in Unity ? Or maybe someone knows how to solve my problem in other way ?

I found this interesting, so I wrote a custom shader that does it:

Shader "Custom/SpecularOnly" {
	Properties {
	  _SpecColor ("Specular Color", Color) = (1,1,1,1)
	  _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
	}
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200
		
		CGPROGRAM
		#pragma surface surf SpecularOnly

		uniform half _Shininess;

		inline fixed4 LightingSpecularOnly (SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
		{
			half3 h = normalize (lightDir + viewDir);
	
			float nh = max (0, dot (s.Normal, h));
			float spec = pow (nh, s.Specular*128.0) * s.Gloss;
	
			fixed4 c;
			c.rgb = (_LightColor0.rgb * _SpecColor.rgb * spec) * (atten * 2);
			c.a = s.Alpha + _LightColor0.a * _SpecColor.a * spec * atten;
			return c;
		}

		struct Input {
			float2 uv_MainTex;
		};

		void surf (Input IN, inout SurfaceOutput o) 
		{
			o.Albedo = float4(0,0,0,1);
			o.Gloss = 1;
			o.Specular = _Shininess;
		}
		ENDCG
	} 
	FallBack "Diffuse"
}

A shader that displays only specular highlights is simply a shader where all other lighting contributions have been omitted, i.e. it has no diffuse contribution, no emissive and no ambient. So I went to the file Lighting.cginc in the Unity install dir and copied the default BlinnPhong Lighting function, then simply removed the diffuse component from it and used that instead as a custom Lighting function in the above shader.

Setting the Albedo to black removes the ambient component, which would’ve otherwise typically rendered the rest of the object dark gray.

This shader renders full black except where the specular highlight is. That gets whatever color you set on the material.