posToLight -= posWorld * lightInput.pos.w;
float distanceSqr = max(dot(posToLight, posToLight), 0.001);
float dist = sqrt(distanceSqr);
// TODO: compute light attenuation from texture to save ALU. Builtin _LightTexture0 not set from SRP but we can create one.
// light attenuation with falloff.
// lightInput.atten.z = kQuadFallOff = (25.0) / (lightRange * lightRange)
// lightInput.atten.w = lightRange * lightRange
// TODO: we can precompute 1.0 / (lightInput.atten.w * 0.64 - lightInput.atten.w)
// falloff is computed from 80% light range squared
float falloff = saturate((distanceSqr - lightInput.atten.w) / (lightInput.atten.w * 0.64 - lightInput.atten.w));
lightAtten *= falloff;
half cutoff = step(distanceSqr, lightInput.atten.w);
lightAtten *= cutoff;
half NdotL = saturate(dot(normal, lightDir));