summaryrefslogtreecommitdiff
path: root/engine/src/rendering/shader
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/rendering/shader')
-rw-r--r--engine/src/rendering/shader/cursor.rs10
-rw-r--r--engine/src/rendering/shader/default.rs28
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"),