fix: make color proper

This commit is contained in:
Nova
2025-10-21 16:44:34 -07:00
parent 2b07345286
commit 181224767d
4 changed files with 8 additions and 12 deletions

6
Cargo.lock generated
View File

@@ -4766,7 +4766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d"
dependencies = [
"anyhow",
"itertools 0.11.0",
"itertools 0.14.0",
"proc-macro2",
"quote",
"syn 2.0.104",
@@ -5448,7 +5448,7 @@ checksum = "6eae92052b72ef70dafa16eddbabffc77e5ca3574be2f7bc1127b36f0a7ad7f2"
[[package]]
name = "stardust-xr"
version = "0.45.0"
source = "git+https://github.com/StardustXR/core.git?branch=dev#d61d268ae60a36f6a42af2cef95807187b6a5532"
source = "git+https://github.com/StardustXR/core.git?branch=dev#c03b8c09c2bc1096aedaf66025d47879729d6d10"
dependencies = [
"color-eyre",
"dirs",
@@ -5467,7 +5467,7 @@ dependencies = [
[[package]]
name = "stardust-xr-schemas"
version = "1.5.3"
source = "git+https://github.com/StardustXR/core.git?branch=dev#d61d268ae60a36f6a42af2cef95807187b6a5532"
source = "git+https://github.com/StardustXR/core.git?branch=dev#c03b8c09c2bc1096aedaf66025d47879729d6d10"
dependencies = [
"console-subscriber",
"flatbuffers",

View File

@@ -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)
}
}

View File

@@ -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 },

View File

@@ -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()
},