From 5ce6133e120bd5e3d7490db1872bc8b667a0fb4f Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 19 May 2024 18:21:53 +0200 Subject: fix(engine): use ambient light from GlobalLight --- engine/src/material.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'engine/src/material.rs') diff --git a/engine/src/material.rs b/engine/src/material.rs index 5e360cd..5c59a9a 100644 --- a/engine/src/material.rs +++ b/engine/src/material.rs @@ -3,6 +3,7 @@ use ecs::Component; use crate::color::Color; use crate::data_types::dimens::Dimens; use crate::texture::{Id as TextureId, Texture}; +use crate::util::builder; #[derive(Debug, Clone, Component)] #[non_exhaustive] @@ -176,6 +177,27 @@ impl Default for Builder } } +builder! { +/// Material flags. +#[builder(name = FlagsBuilder, derives = (Debug, Default, Clone))] +#[derive(Debug, Default, Clone, Component)] +#[non_exhaustive] +pub struct Flags +{ + /// Whether to use material's ambient color instead of the global ambient color. + /// Default is `false` + pub use_ambient_color: bool, +} +} + +impl Flags +{ + pub fn builder() -> FlagsBuilder + { + FlagsBuilder::default() + } +} + fn create_1x1_white_texture() -> Texture { Texture::new_from_color(&Dimens { width: 1, height: 1 }, &Color::WHITE_U8) -- cgit v1.2.3-18-g5258