diff --git a/src/main.rs b/src/main.rs index ff7768f..877af2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,6 @@ use bevy_mod_openxr::resources::{OxrFrameState, OxrFrameWaiter, OxrSessionConfig use bevy_mod_openxr::types::AppInfo; use bevy_mod_xr::camera::XrProjection; use bevy_mod_xr::session::{XrFirst, XrHandleEvents, XrSessionPlugin}; -use bevy_sk::vr_materials::PbrMaterial; use clap::Parser; use core::client::{Client, tick_internal_client}; use core::entity_handle::EntityHandlePlugin; @@ -106,7 +105,7 @@ struct CliArgs { restore: Option, } -pub type BevyMaterial = PbrMaterial; +pub type BevyMaterial = StandardMaterial; static STARDUST_INSTANCE: OnceLock = OnceLock::new(); diff --git a/src/nodes/drawable/lines.rs b/src/nodes/drawable/lines.rs index d12e617..32bb927 100644 --- a/src/nodes/drawable/lines.rs +++ b/src/nodes/drawable/lines.rs @@ -154,8 +154,8 @@ fn build_line_mesh( Name::new("LinesNode"), SpatialNode(Arc::downgrade(&lines.spatial)), MeshMaterial3d(materials.add(BevyMaterial { - color: Color::WHITE, - roughness: 1.0, + base_color: Color::WHITE, + perceptual_roughness: 1.0, alpha_mode: AlphaMode::Opaque, ..default() })), diff --git a/src/nodes/drawable/model.rs b/src/nodes/drawable/model.rs index 67680ce..bc03eb8 100644 --- a/src/nodes/drawable/model.rs +++ b/src/nodes/drawable/model.rs @@ -275,10 +275,10 @@ impl HashedPbrMaterial { Self(hasher.finish()) } fn hash_pbr_mat(mat: &BevyMaterial, state: &mut H) { - hash_color(mat.color, state); - hash_color(mat.emission_factor.into(), state); + hash_color(mat.base_color, state); + hash_color(mat.emissive.into(), state); state.write_u32(mat.metallic.to_bits()); - state.write_u32(mat.roughness.to_bits()); + state.write_u32(mat.perceptual_roughness.to_bits()); match mat.alpha_mode { AlphaMode::Opaque => state.write_u8(0), AlphaMode::Mask(v) => { @@ -292,9 +292,9 @@ impl HashedPbrMaterial { AlphaMode::Multiply => state.write_u8(6), } state.write_u8(mat.double_sided as u8); - mat.diffuse_texture.hash(state); - mat.emission_texture.hash(state); - mat.metal_texture.hash(state); + mat.base_color_texture.hash(state); + mat.emissive_texture.hash(state); + mat.metallic_roughness_texture.hash(state); mat.occlusion_texture.hash(state); // should always be the same, TODO: make the spherical harmonics buffer a per mesh instance thing // mat.spherical_harmonics.hash(state); @@ -388,7 +388,7 @@ impl MaterialParameter { MaterialParameter::Float(val) => { match parameter_name { "metallic" => mat.metallic = *val, - "roughness" => mat.roughness = *val, + "roughness" => mat.perceptual_roughness = *val, // we probably don't want to expose tex_scale // "tex_scale" => mat.tex_scale = *val, v => { @@ -403,8 +403,8 @@ impl MaterialParameter { // nothing uses a Vec3 } MaterialParameter::Color(color) => match parameter_name { - "color" => mat.color = color.to_bevy(), - "emission_factor" => mat.emission_factor = color.to_bevy(), + "color" => mat.base_color = color.to_bevy(), + "emission_factor" => mat.emissive = color.to_bevy().to_linear(), v => { error!("unknown param_name ({v}) for color") } @@ -417,9 +417,9 @@ impl MaterialParameter { }; let handle = asset_server.load(texture_path); match parameter_name { - "diffuse" => mat.diffuse_texture = Some(handle), - "emission" => mat.emission_texture = Some(handle), - "metal" => mat.metal_texture = Some(handle), + "diffuse" => mat.base_color_texture = Some(handle), + "emission" => mat.emissive_texture = Some(handle), + "metal" => mat.metallic_roughness_texture = Some(handle), "occlusion" => mat.occlusion_texture = Some(handle), v => { error!("unknown param_name ({v}) for texture"); diff --git a/src/nodes/drawable/text.rs b/src/nodes/drawable/text.rs index c777570..1fd6906 100644 --- a/src/nodes/drawable/text.rs +++ b/src/nodes/drawable/text.rs @@ -92,10 +92,10 @@ fn spawn_text( text: text_string, material: material_registry.get_handle( BevyMaterial { - color: style.color.to_bevy(), - emission_factor: Color::WHITE, + base_color: style.color.to_bevy(), + emissive: Color::WHITE.to_linear(), metallic: 0.0, - roughness: 1.0, + perceptual_roughness: 1.0, // If alpha is supported on text we need to change this alpha_mode: AlphaMode::Opaque, double_sided: false, diff --git a/src/objects/input/oxr_hand.rs b/src/objects/input/oxr_hand.rs index 91c9448..1641c8f 100644 --- a/src/objects/input/oxr_hand.rs +++ b/src/objects/input/oxr_hand.rs @@ -219,10 +219,10 @@ impl OxrHandInput { let input = InputMethod::add_to(&node.0, hand, datamap)?; let material = materials.add(BevyMaterial { - color: Srgba::new(1.0, 1.0, 1.0, 1.0).into(), + base_color: Srgba::new(1.0, 1.0, 1.0, 1.0).into(), alpha_mode: AlphaMode::Blend, - diffuse_texture: Some(GRADIENT_TEXTURE_HANDLE), - roughness: 1.0, + base_color_texture: Some(GRADIENT_TEXTURE_HANDLE), + perceptual_roughness: 1.0, ..default() }); Ok(OxrHandInput { @@ -329,10 +329,10 @@ impl OxrHandInput { *self.input.datamap.lock() = Datamap::from_typed(&self.datamap).unwrap(); let captured = self.capture_manager.capture.upgrade().is_some(); if captured && !self.captured { - materials.get_mut(&self.material).unwrap().color = + materials.get_mut(&self.material).unwrap().base_color = Srgba::rgb(0., 1., 0.75).into(); } else if self.captured && !captured { - materials.get_mut(&self.material).unwrap().color = + materials.get_mut(&self.material).unwrap().base_color = Srgba::rgb(1., 1.0, 1.0).into(); } self.captured = captured; diff --git a/src/wayland/core/surface.rs b/src/wayland/core/surface.rs index 9543468..b1b3d02 100644 --- a/src/wayland/core/surface.rs +++ b/src/wayland/core/surface.rs @@ -141,7 +141,7 @@ impl Surface { materials .get_mut(material) .unwrap() - .diffuse_texture + .base_color_texture .replace(new_tex); // For SHM buffers, we can release immediately after copying to GPU