Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct BaseLight
- {
- vec3 color;
- float intensity;
- };
- struct Attenuation{
- float constant;
- float linear;
- float exponent;
- };
- struct PointLight{
- BaseLight base;
- Attenuation atten;
- vec3 pos;
- float range;
- };
- struct SpotLight{
- PointLight point;
- vec3 direction;
- float cutoff;
- };
- vec4 calcSpotLight(SpotLight spotLight, vec3 normal){
- vec3 lightDirection = normalize(worldPos0 - spotLight.point.pos);
- float spotFactor = dot(lightDirection, spotLight.direction);
- vec4 color = vec4(0,0,0,0);
- if (spotFactor > spotLight.cutoff){
- color = calcPointLight(spotLight.point, normal) *
- (1.0 - ((1.0 - spotFactor)/(1.0 - spotLight.cutoff)));
- }
- return color;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement