summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-09-23 19:11:29 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-09-23 19:11:29 -0400
commit8c2386442a60bac743a6e80d5ba024efe92958c5 (patch)
treeb4310da68f18a8480ae256af02b15a9e7c1d8ddc /data
parentf570211fdf973dcbd4115a2f2a685eec87ed8080 (diff)
graphics: light: Add intensity field.
Diffstat (limited to 'data')
-rw-r--r--data/shaders/pbr-frag.glsl5
-rw-r--r--data/shaders/phong-frag.glsl5
2 files changed, 6 insertions, 4 deletions
diff --git a/data/shaders/pbr-frag.glsl b/data/shaders/pbr-frag.glsl
index fff725a..e6bcdc5 100644
--- a/data/shaders/pbr-frag.glsl
+++ b/data/shaders/pbr-frag.glsl
@@ -20,6 +20,7 @@ struct Light {
vec3 position;
vec3 direction;
vec4 color;
+ float intensity;
float cutOff;
};
@@ -210,14 +211,14 @@ vec3 lightDirection(Light light) {
vec3 lightAttenuate(Light light) {
float distance = length(light.position - fragWorldPos);
float attenuation = 1.0 / (distance * distance);
- return light.color.rgb * attenuation;
+ return light.color.rgb * light.intensity * attenuation;
}
vec3 lightRadiance(Light light, vec3 direction) {
if(light.type == 0) { // point light
return lightAttenuate(light);
} else if(light.type == 1) { // directional light
- return light.color.rgb;
+ return light.color.rgb * light.intensity;
} else if(light.type == 2) { // spot light
float theta = dot(direction, normalize(-light.direction));
// Spot lights only shine light in a specific conical area.
diff --git a/data/shaders/phong-frag.glsl b/data/shaders/phong-frag.glsl
index 9c86c83..b07c8b0 100644
--- a/data/shaders/phong-frag.glsl
+++ b/data/shaders/phong-frag.glsl
@@ -13,6 +13,7 @@ struct Light {
vec3 position;
vec3 direction;
vec4 color;
+ float intensity;
float cutOff;
};
@@ -71,14 +72,14 @@ vec3 lightDirection(Light light) {
vec3 lightAttenuate(Light light) {
float distance = length(light.position - fragWorldPos);
float attenuation = 1.0 / (distance * distance);
- return light.color.rgb * attenuation;
+ return light.color.rgb * light.intensity * attenuation;
}
vec3 lightRadiance(Light light, vec3 direction) {
if(light.type == 0) { // point light
return lightAttenuate(light);
} else if(light.type == 1) { // directional light
- return light.color.rgb;
+ return light.color.rgb * light.intensity;
} else if(light.type == 2) { // spot light
float theta = dot(direction, normalize(-light.direction));
// Spot lights only shine light in a specific conical area.