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:
parent
e8ae0d6c49
commit
faa2ce4d55
@ -1,3 +1,5 @@
|
|||||||
|
use std::ops::{Div, Mul};
|
||||||
|
|
||||||
use crate::color_difference::EuclideanDistance;
|
use crate::color_difference::EuclideanDistance;
|
||||||
use crate::{Alpha, LinearRgba, Luminance, Mix, StandardColor, Xyza};
|
use crate::{Alpha, LinearRgba, Luminance, Mix, StandardColor, Xyza};
|
||||||
use bevy_math::Vec4;
|
use bevy_math::Vec4;
|
||||||
@ -369,6 +371,48 @@ pub enum HexColorError {
|
|||||||
Char(char),
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::testing::assert_approx_eq;
|
use crate::testing::assert_approx_eq;
|
||||||
|
@ -36,8 +36,7 @@ fn add_lightmaps_to_meshes(
|
|||||||
let exposure = 250.0;
|
let exposure = 250.0;
|
||||||
for (entity, name, material) in meshes.iter() {
|
for (entity, name, material) in meshes.iter() {
|
||||||
if &**name == "Light" {
|
if &**name == "Light" {
|
||||||
materials.get_mut(material).unwrap().emissive =
|
materials.get_mut(material).unwrap().emissive = Color::Srgba(Srgba::WHITE * exposure);
|
||||||
Color::LinearRgba(LinearRgba::WHITE * exposure);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user