summaryrefslogtreecommitdiff
path: root/engine/light.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'engine/light.glsl')
-rw-r--r--engine/light.glsl16
1 files changed, 14 insertions, 2 deletions
diff --git a/engine/light.glsl b/engine/light.glsl
index 49026ec..04a42f5 100644
--- a/engine/light.glsl
+++ b/engine/light.glsl
@@ -13,14 +13,17 @@ struct Material {
float shininess;
};
-struct Light {
+struct PointLight {
vec3 position;
vec3 diffuse;
vec3 specular;
+ float constant;
+ float linear;
+ float quadratic;
};
uniform Material material;
-uniform Light light;
+uniform PointLight light;
vec3 calc_ambient_light(in vec2 texture_coords)
{
@@ -56,4 +59,13 @@ vec3 calc_specular_light(
);
}
+float calc_attenuation(in PointLight point_light, in vec3 position)
+{
+ float light_distance = length(point_light.position - position);
+
+ return 1.0 / (point_light.constant + point_light.linear
+ * light_distance + point_light.quadratic
+ * pow(light_distance, 2));
+}
+
#endif