From 0f53ae83a4d8da002850859fe0d010c5df4f2f57 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 22 May 2024 19:23:19 +0200 Subject: refactor(engine): remove ambient color from shader Light struct --- engine/light.glsl | 6 +----- engine/src/renderer/mod.rs | 15 +-------------- 2 files changed, 2 insertions(+), 19 deletions(-) (limited to 'engine') 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 @@ -371,16 +371,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 @@ -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(), ); -- cgit v1.2.3-18-g5258