diff options
| author | HampusM <hampus@hampusmat.com> | 2026-07-17 03:06:04 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-07-17 03:06:04 +0200 |
| commit | 65e24308babb2ed4f33fb6f1d7b531df676bd70d (patch) | |
| tree | df9477d4b805cc6866a086833d6118505804dd3a /engine/src/rendering/shader | |
| parent | 649d4d4ab2f54ca12f75d2cba50e1adef2350dbe (diff) | |
refactor(engine): change Color struct into a enum
Diffstat (limited to 'engine/src/rendering/shader')
| -rw-r--r-- | engine/src/rendering/shader/cursor.rs | 10 | ||||
| -rw-r--r-- | engine/src/rendering/shader/default.rs | 28 |
2 files changed, 23 insertions, 15 deletions
diff --git a/engine/src/rendering/shader/cursor.rs b/engine/src/rendering/shader/cursor.rs index 17f5748..8aab4f2 100644 --- a/engine/src/rendering/shader/cursor.rs +++ b/engine/src/rendering/shader/cursor.rs @@ -1,3 +1,4 @@ +use crate::color::Color; use crate::data_types::matrix::Matrix; use crate::data_types::vector::Vec3; use crate::rendering::object::Id as RenderingObjectId; @@ -114,6 +115,7 @@ pub enum BindingValue Int(i32), Float(f32), FVec3(Vec3<f32>), + Color(Color<f32>), FMat4x4(Matrix<f32, 4, 4>), Texture(RenderingObjectId), } @@ -150,6 +152,14 @@ impl From<Vec3<f32>> for BindingValue } } +impl From<Color<f32>> for BindingValue +{ + fn from(color: Color<f32>) -> Self + { + BindingValue::Color(color) + } +} + impl From<Matrix<f32, 4, 4>> for BindingValue { fn from(matrix: Matrix<f32, 4, 4>) -> Self diff --git a/engine/src/rendering/shader/default.rs b/engine/src/rendering/shader/default.rs index 3194706..bb5c366 100644 --- a/engine/src/rendering/shader/default.rs +++ b/engine/src/rendering/shader/default.rs @@ -142,7 +142,7 @@ pub fn enqueue_set_shader_bindings( MaterialSearchResult::NotFound => { continue; } - MaterialSearchResult::NoMaterials => &const { Material::builder().build() }, + MaterialSearchResult::NoMaterials => &Material::builder().build(), }; if [ @@ -181,23 +181,21 @@ pub fn enqueue_set_shader_bindings( ), ( material_shader_cursor.field("ambient"), - Vec3::from( - if material_flags.use_ambient_color { - &model_material.ambient - } else { - &global_light.ambient - } - .clone(), - ) + (if material_flags.use_ambient_color { + &model_material.ambient + } else { + &global_light.ambient + } + .clone()) .into(), ), ( material_shader_cursor.field("diffuse"), - Vec3::from(model_material.diffuse.clone()).into(), + model_material.diffuse.clone().into(), ), ( material_shader_cursor.field("specular"), - Vec3::from(model_material.specular.clone()).into(), + model_material.specular.clone().into(), ), ( material_shader_cursor.field("shininess"), @@ -243,11 +241,11 @@ pub fn enqueue_set_shader_bindings( [ ( phong_shader_cursor.field("diffuse"), - Vec3::from(point_light.diffuse.clone()).into(), + point_light.diffuse.clone().into(), ), ( phong_shader_cursor.field("specular"), - Vec3::from(point_light.specular.clone()).into(), + point_light.specular.clone().into(), ), ( point_light_shader_cursor.field("position"), @@ -281,11 +279,11 @@ pub fn enqueue_set_shader_bindings( [ ( phong_shader_cursor.field("diffuse"), - Vec3::from(directional_light.diffuse.clone()).into(), + directional_light.diffuse.clone().into(), ), ( phong_shader_cursor.field("specular"), - Vec3::from(directional_light.specular.clone()).into(), + directional_light.specular.clone().into(), ), ( directional_light_shader_cursor.field("direction"), |
