fix example lightmaps after color migration (#12265)

# Objective

- Since #12163 example lightmaps is more dull
<img width="1280" alt="Screenshot 2024-03-02 at 23 04 36"
src="https://github.com/bevyengine/bevy/assets/8672791/7736f420-b9c5-4870-93f6-b5b992c4768a">


## Solution

- Use a srgba color, as it was before:

b24ab2e9fb/examples/3d/lightmaps.rs (L39)

b24ab2e9fb/crates/bevy_render/src/color/mod.rs (L132)

<img width="1280" alt="Screenshot 2024-03-02 at 23 05 09"
src="https://github.com/bevyengine/bevy/assets/8672791/451187ed-8612-456f-ad25-180d5f774188">
This commit is contained in:
François 2024-03-03 22:36:11 +01:00 committed by GitHub
parent e8ae0d6c49
commit faa2ce4d55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 2 deletions

View File

@ -1,3 +1,5 @@
use std::ops::{Div, Mul};
use crate::color_difference::EuclideanDistance;
use crate::{Alpha, LinearRgba, Luminance, Mix, StandardColor, Xyza};
use bevy_math::Vec4;
@ -369,6 +371,48 @@ pub enum HexColorError {
Char(char),
}
/// All color channels are scaled directly,
/// but alpha is unchanged.
///
/// Values are not clamped.
impl Mul<f32> for Srgba {
type Output = Self;
fn mul(self, rhs: f32) -> Self {
Self {
red: self.red * rhs,
green: self.green * rhs,
blue: self.blue * rhs,
alpha: self.alpha,
}
}
}
impl Mul<Srgba> for f32 {
type Output = Srgba;
fn mul(self, rhs: Srgba) -> Srgba {
rhs * self
}
}
/// All color channels are scaled directly,
/// but alpha is unchanged.
///
/// Values are not clamped.
impl Div<f32> for Srgba {
type Output = Self;
fn div(self, rhs: f32) -> Self {
Self {
red: self.red / rhs,
green: self.green / rhs,
blue: self.blue / rhs,
alpha: self.alpha,
}
}
}
#[cfg(test)]
mod tests {
use crate::testing::assert_approx_eq;

View File

@ -36,8 +36,7 @@ fn add_lightmaps_to_meshes(
let exposure = 250.0;
for (entity, name, material) in meshes.iter() {
if &**name == "Light" {
materials.get_mut(material).unwrap().emissive =
Color::LinearRgba(LinearRgba::WHITE * exposure);
materials.get_mut(material).unwrap().emissive = Color::Srgba(Srgba::WHITE * exposure);
continue;
}