float custom_factor = 1;
for(int i = 0; i < 8; i++)
{
if(vecLightDir[i].w > 0) // spotlight ?
{
float3 light_ray = Out.WorldPos - vecLightPos[i].xyz;
float depth = dot(vecLightDir[i], light_ray);
// saturate clips the value between 0 and 1
// any negative value will result in 0, and any value above 1 wiil result in 1.
float depth_factor = saturate(depth / vecLightPos[i].w);
float radius = length(cross(vecLightDir[i], light_ray));
float spot_factor = 1.0 - saturate(radius / (vecLightPos[i].w * depth_factor * custom_factor));
}
}