summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-05-22 19:23:19 +0200
committerHampusM <hampus@hampusmat.com>2024-05-22 19:23:19 +0200
commit0f53ae83a4d8da002850859fe0d010c5df4f2f57 (patch)
tree9dc72bd905ac1e6a5b272a63450b1f0265ac2253 /engine
parentf06880383420da3f8d14079817ff271e71791abb (diff)
refactor(engine): remove ambient color from shader Light struct
Diffstat (limited to 'engine')
-rw-r--r--engine/light.glsl6
-rw-r--r--engine/src/renderer/mod.rs15
2 files changed, 2 insertions, 19 deletions
diff --git a/engine/light.glsl b/engine/light.glsl
index 46105e9..49026ec 100644
--- a/engine/light.glsl
+++ b/engine/light.glsl
@@ -15,8 +15,6 @@ struct Material {
struct Light {
vec3 position;
-
- vec3 ambient;
vec3 diffuse;
vec3 specular;
};
@@ -26,9 +24,7 @@ uniform Light light;
vec3 calc_ambient_light(in vec2 texture_coords)
{
- return light.ambient * (
- vec3(texture(material.ambient_map, texture_coords)) * material.ambient
- );
+ return vec3(texture(material.ambient_map, texture_coords)) * material.ambient;
}
vec3 calc_diffuse_light(in vec3 light_dir, in vec3 norm, in vec2 texture_coords)
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs
index 4f9d7e6..d843020 100644
--- a/engine/src/renderer/mod.rs
+++ b/engine/src/renderer/mod.rs
@@ -372,16 +372,6 @@ fn apply_light(
);
gl_shader_program.set_uniform_vec_3fv(
- cstr!("light.ambient"),
- // There cannot be both a material ambient color and a global ambient color
- &if material_flags.use_ambient_color {
- Color::WHITE_F32.into()
- } else {
- global_light.ambient.clone().into()
- },
- );
-
- gl_shader_program.set_uniform_vec_3fv(
cstr!("light.diffuse"),
&light_source
.map_or(Color::WHITE_F32, |(light_source, _)| {
@@ -401,13 +391,10 @@ fn apply_light(
gl_shader_program.set_uniform_vec_3fv(
cstr!("material.ambient"),
- // When using the material ambient color is disabled, the ambient color has to be
- // white and not black since the material's ambient color is multiplied
- // with the global ambient light in the shader
&if material_flags.use_ambient_color {
material.ambient.clone()
} else {
- Color::WHITE_F32
+ global_light.ambient.clone().into()
}
.into(),
);