ually generate a branch. The compiler translates this into
    //       an instruction (slt) that returns 0 or 1 and multiplies that times the output color
    if (dot(VecToLight, TransformedNormal) > 0)
    {
        float DistToLight = length(VecToLight);
        // normalize L
        VecToLight /= DistToLight;

        // in WorldView space, the camera is at <0> so just invert the position
        float3 HalfVector = normalize(normalize(-TransformedPosition.xyz) + VecToLight);

        // the max is to ensure that the attenuation only diminishes the light
        float atten = 1.0 / max(Data.AttenAndRange.x
                                + Data.AttenAndRange.y * DistToLight
                                + Data.AttenAndRange.z * DistToLight * DistToLight,
                                1.0);

        float rho = max(dot(Data.Direction, VecToLight), 0);
        // CosHalfPhiAndCosDiff.x = cos(Phi/2)
        // CosHalfPhiAndCosDiff.y = cos(Theta/2) - cos(Phi/2)
        float spot = saturate((rho - Data.CosHalfPhiAndCosDiff.x) / Data.CosHalfPhiAndCosDiff.y);

        // AttenAndRange.w is the light's range
        Output.Diffuse.rgb += Data.Color.rgb
                              * pow(max(dot(TransformedNormal, HalfVector), 0), SpecularPower)

                              * atten
                              * spot
                              * step(DistToLight, Data.AttenAndRange.w);
    }
}
