I recently stumbled across this thread when searching for a way to customise light falloff in the standard shader and was hoping somebody here could help me take it a ways further. What I want to do is have no falloff at all. Instead, I want a perfectly sharp terminator and consistent shadow darkness.
I know this sounds counterintuitive to most modern game graphics design, but I have my reasons. I’ve been messing about with UnityDeferredLibrary.cginc and have identified the two places I need to be editing for my needs.
// spot light case
#if defined (SPOT)
float3 tolight = _LightPos.xyz - wpos;
half3 lightDir = normalize (tolight);
float4 uvCookie = mul (_LightMatrix0, float4(wpos,1));
float atten = tex2Dproj (_LightTexture0, UNITY_PROJ_COORD(uvCookie)).w;
atten *= uvCookie.w < 0;
float att = dot(tolight, tolight) * _LightPos.w;
atten *= tex2D (_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL;
atten *= UnityDeferredComputeShadow (wpos, fadeDist, uv);
// point light case
#elif defined (POINT) || defined (POINT_COOKIE)
float3 tolight = wpos - _LightPos.xyz;
half3 lightDir = -normalize (tolight);
float att = dot(tolight, tolight) * _LightPos.w;
float atten = tex2D (_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL;
atten *= UnityDeferredComputeShadow (tolight, fadeDist, uv);
#if defined (POINT_COOKIE)
atten *= texCUBE(_LightTexture0, mul(_LightMatrix0, half4(wpos,1)).xyz).w;
#endif //POINT_COOKIE
#else
half3 lightDir = 0;
float atten = 0;
#endif
Unfortunately, that’s where I end up stumped. I’m not sure how I’m supposed to change the atten value or where to achieve the results I want. Can anyone help me with this, please?