#ifndef _SPOTLIGHT_CG_
#define _SPOTLIGHT_CG_

#include "light.cg"

struct SpotLight : Light {
    float3 Plight, Clight, target;
    bool enabled;
    float3 illuminate(float3 P, out float3 L) {
        L = normalize(Plight - P);
        float3 shine = normalize(Plight - target);
        float costheta = dot(L, shine);
        return Clight * smoothstep(0.98, 1., costheta);
    }
    bool isEnabled(void) { return enabled; }
};

#endif // _SPOTLIGHT_CG_
