diff options
author | HampusM <hampus@hampusmat.com> | 2024-05-22 20:39:26 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-05-22 20:39:26 +0200 |
commit | d4b61dd34b06119e87c8932ab7718d432dbc6a4f (patch) | |
tree | 2240158176c11eac545a1b50bbe644700b67ab51 /engine/src/renderer/mod.rs | |
parent | 8398025d7927564637e1ea67234665571dc7bcc5 (diff) |
feat(engine): add point light attenuation
Diffstat (limited to 'engine/src/renderer/mod.rs')
-rw-r--r-- | engine/src/renderer/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs index e736165..ad587b5 100644 --- a/engine/src/renderer/mod.rs +++ b/engine/src/renderer/mod.rs @@ -389,6 +389,27 @@ fn apply_light( .into(), ); + gl_shader_program.set_uniform_1fv( + cstr!("light.constant"), + point_light.map_or(1.0, |(light_source, _)| { + light_source.attenuation_params.constant + }), + ); + + gl_shader_program.set_uniform_1fv( + cstr!("light.linear"), + point_light.map_or(0.0, |(light_source, _)| { + light_source.attenuation_params.linear + }), + ); + + gl_shader_program.set_uniform_1fv( + cstr!("light.quadratic"), + point_light.map_or(0.0, |(light_source, _)| { + light_source.attenuation_params.quadratic + }), + ); + gl_shader_program.set_uniform_vec_3fv( cstr!("material.ambient"), &if material_flags.use_ambient_color { |