fix: fix alpha blending, suboptimal since it doesn't support prelutiplied alpha but its fine for now
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_mod_openxr::{
|
use bevy_mod_openxr::{
|
||||||
add_xr_plugins, features::overlay::OxrOverlaySessionEvent, init::OxrInitPlugin,
|
add_xr_plugins,
|
||||||
resources::OxrSessionConfig, types::OxrExtensions,
|
features::overlay::{OxrOverlaySessionEvent, OxrOverlaySettings},
|
||||||
|
init::OxrInitPlugin,
|
||||||
|
resources::OxrSessionConfig,
|
||||||
|
types::OxrExtensions,
|
||||||
};
|
};
|
||||||
use openxr::EnvironmentBlendMode;
|
use openxr::EnvironmentBlendMode;
|
||||||
|
|
||||||
@@ -18,6 +21,10 @@ fn main() {
|
|||||||
},
|
},
|
||||||
..OxrInitPlugin::default()
|
..OxrInitPlugin::default()
|
||||||
}))
|
}))
|
||||||
|
.insert_resource(OxrOverlaySettings {
|
||||||
|
session_layer_placement: 300,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
.insert_resource(OxrSessionConfig {
|
.insert_resource(OxrSessionConfig {
|
||||||
blend_mode_preference: {
|
blend_mode_preference: {
|
||||||
vec![
|
vec![
|
||||||
@@ -82,7 +89,11 @@ fn setup(
|
|||||||
// cube
|
// cube
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
|
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
|
||||||
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
|
MeshMaterial3d(materials.add(StandardMaterial {
|
||||||
|
base_color: Color::srgba_u8(124, 144, 255, 127),
|
||||||
|
alpha_mode: AlphaMode::Blend,
|
||||||
|
..Default::default()
|
||||||
|
})),
|
||||||
Transform::from_xyz(0.0, 2.5, 0.0),
|
Transform::from_xyz(0.0, 2.5, 0.0),
|
||||||
));
|
));
|
||||||
// light
|
// light
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ impl LayerProvider for ProjectionLayer {
|
|||||||
|
|
||||||
Some(Box::new(
|
Some(Box::new(
|
||||||
CompositionLayerProjection::new()
|
CompositionLayerProjection::new()
|
||||||
.layer_flags(CompositionLayerFlags::BLEND_TEXTURE_SOURCE_ALPHA)
|
.layer_flags(
|
||||||
|
CompositionLayerFlags::BLEND_TEXTURE_SOURCE_ALPHA
|
||||||
|
| CompositionLayerFlags::UNPREMULTIPLIED_ALPHA,
|
||||||
|
)
|
||||||
.space(stage)
|
.space(stage)
|
||||||
.views(&[
|
.views(&[
|
||||||
CompositionLayerProjectionView::new()
|
CompositionLayerProjectionView::new()
|
||||||
@@ -171,7 +174,7 @@ impl Default for CompositionLayerProjectionView<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// the header function must return a ref to a valid Composition Layer struct.
|
/// the header function must return a ref to a valid Composition Layer struct.
|
||||||
/// it has to use `repr(C)` and it has to follow the shape of a Composition Layer struct from the
|
/// it has to use `repr(C)` and it has to follow the shape of a Composition Layer struct from the
|
||||||
/// OpenXR specification
|
/// OpenXR specification
|
||||||
pub unsafe trait CompositionLayer<'a> {
|
pub unsafe trait CompositionLayer<'a> {
|
||||||
|
|||||||
Reference in New Issue
Block a user