WrapLambert Question

I’m using the WrapLambert lighting model in one of my shaders. Does anyone know if its possibly to change the values in it as the distance away from an object changes? Here’s what I’m working with :

half4 LightingWrapLambert (SurfaceOutput s, half3 lightDir, half atten) {
		half NdotL = dot (s.Normal, lightDir);
		half diff = NdotL * .5 + .25;
		half4 c;
		c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
		c.a = s.Alpha;
		return c;
	}

I want it to change from half diff = NdotL * .5 + .25; when far away from an object to half diff = NdotL * .5 + .8; when close.

Do you need the cutoff range to be computed per-fragment, or could you just put your lighting boost value into the shader as a property, and have a script change it based on object range?

Daniel,

I suppose a script would do the trick. Care to get me started in the right direction?

Much Appreciated

You need to add a property to your shader so it can be changed through the Material, and then access the property from inside the lighting function. You can see some examples of float properties being added in the Rim Lighting example.