fix: make color proper
This commit is contained in:
@@ -3,10 +3,8 @@ use stardust_xr::values::color::{AlphaColor, Rgb, color_space::LinearRgb};
|
||||
pub trait ColorConvert {
|
||||
fn to_bevy(&self) -> bevy::color::Color;
|
||||
}
|
||||
// even tho its supposed to be linear the values have to be interpreted as Srgba to produce the
|
||||
// correct result because StereoKit used Srgba while it was assumed that is uses linear rgba
|
||||
impl ColorConvert for AlphaColor<f32, Rgb<f32, LinearRgb>> {
|
||||
fn to_bevy(&self) -> bevy::color::Color {
|
||||
bevy::color::Color::srgba(self.c.r, self.c.g, self.c.b, self.a)
|
||||
bevy::color::Color::linear_rgba(self.c.r, self.c.g, self.c.b, self.a)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ fn build_line_mesh(
|
||||
let points = normals.map(|v| (v * curr.thickness) + Vec3::from(curr.point));
|
||||
vertex_normals.extend(normals);
|
||||
vertex_positions.extend(points);
|
||||
vertex_colors.extend([curr.color.to_bevy().to_srgba().to_f32_array(); 8]);
|
||||
vertex_colors.extend([curr.color.to_bevy().to_linear().to_f32_array(); 8]);
|
||||
// Only connect vertices between segments if this isn't the end point
|
||||
if !last_point {
|
||||
vertex_indices.extend(indices(indices_set));
|
||||
@@ -220,9 +220,8 @@ fn build_line_mesh(
|
||||
base: BevyMaterial {
|
||||
base_color: Color::WHITE,
|
||||
perceptual_roughness: 1.0,
|
||||
// TODO: this should be Blend
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
emissive: Color::srgba_u8(128 / 4, 128 / 4, 128 / 4, 255).into(),
|
||||
alpha_mode: AlphaMode::Premultiplied,
|
||||
emissive: Color::linear_rgba(0.25, 0.25, 0.25, 1.0).into(),
|
||||
..default()
|
||||
},
|
||||
extension: LineExtension { unused: 0 },
|
||||
|
||||
@@ -107,8 +107,7 @@ fn spawn_text(
|
||||
emissive: Color::WHITE.to_linear(),
|
||||
metallic: 0.0,
|
||||
perceptual_roughness: 1.0,
|
||||
// If alpha is supported on text we need to change this
|
||||
alpha_mode: AlphaMode::Opaque,
|
||||
alpha_mode: AlphaMode::Premultiplied,
|
||||
double_sided: false,
|
||||
..default()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user