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