openxr: support changing overlay opacity
This commit is contained in:
@@ -100,10 +100,6 @@ or alternatively add the following to `Cargo.toml` to only do basic optimization
|
||||
opt-level = 1
|
||||
```
|
||||
|
||||
## OpenXR: Overlay opacity
|
||||
|
||||
Translucent overlays are not supported on OpenXR yet.
|
||||
|
||||
## Scroll wheel doesn't work
|
||||
|
||||
This seems to be an issue specific to Electron apps (Discord, Element, Slack, Spotify) on Wayland. Scrolling will work when using these in your web browser.
|
||||
|
||||
@@ -4,8 +4,8 @@ use anyhow::bail;
|
||||
use ovr_overlay::{
|
||||
input::{ActionHandle, ActionSetHandle, ActiveActionSet, InputManager, InputValueHandle},
|
||||
sys::{
|
||||
k_unMaxTrackedDeviceCount, ETrackedControllerRole, ETrackedDeviceClass,
|
||||
ETrackedDeviceProperty, ETrackingUniverseOrigin,
|
||||
ETrackedControllerRole, ETrackedDeviceClass, ETrackedDeviceProperty,
|
||||
ETrackingUniverseOrigin,
|
||||
},
|
||||
system::SystemManager,
|
||||
TrackedDeviceIndex,
|
||||
|
||||
@@ -135,10 +135,11 @@ impl LinePool {
|
||||
if let Some(inner) = line.maybe_line.take() {
|
||||
let quad = xr::CompositionLayerQuad::new()
|
||||
.pose(inner.pose)
|
||||
.sub_image(
|
||||
line.swapchain
|
||||
.acquire_present_release(command_buffer, inner.view),
|
||||
)
|
||||
.sub_image(line.swapchain.acquire_present_release(
|
||||
command_buffer,
|
||||
inner.view,
|
||||
1.0,
|
||||
))
|
||||
.eye_visibility(xr::EyeVisibility::BOTH)
|
||||
.layer_flags(xr::CompositionLayerFlags::CORRECT_CHROMATIC_ABERRATION)
|
||||
.space(&xr.stage)
|
||||
|
||||
@@ -50,7 +50,7 @@ impl OverlayData<OpenXrOverlayData> {
|
||||
srd
|
||||
});
|
||||
|
||||
let sub_image = data.acquire_present_release(command_buffer, my_view);
|
||||
let sub_image = data.acquire_present_release(command_buffer, my_view, self.state.alpha);
|
||||
let posef = helpers::transform_to_posef(&self.state.transform);
|
||||
|
||||
let aspect_ratio = extent[1] as f32 / extent[0] as f32;
|
||||
|
||||
@@ -87,6 +87,7 @@ impl SwapchainRenderData {
|
||||
&mut self,
|
||||
command_buffer: &mut WlxCommandBuffer,
|
||||
view: Arc<ImageView>,
|
||||
alpha: f32,
|
||||
) -> xr::SwapchainSubImage<xr::Vulkan> {
|
||||
let idx = self.swapchain.acquire_image().unwrap() as usize;
|
||||
self.swapchain.wait_image(xr::Duration::INFINITE).unwrap();
|
||||
@@ -95,14 +96,18 @@ impl SwapchainRenderData {
|
||||
command_buffer.begin_rendering(render_target.clone());
|
||||
|
||||
let target_extent = render_target.image().extent();
|
||||
let set = self
|
||||
|
||||
let set0 = self
|
||||
.pipeline
|
||||
.uniform_sampler(0, view.clone(), Filter::Linear);
|
||||
|
||||
let set1 = self.pipeline.uniform_buffer(1, vec![alpha]);
|
||||
|
||||
let pass = self.pipeline.create_pass(
|
||||
[target_extent[0] as _, target_extent[1] as _],
|
||||
command_buffer.graphics.quad_verts.clone(),
|
||||
command_buffer.graphics.quad_indices.clone(),
|
||||
vec![set],
|
||||
vec![set0, set1],
|
||||
);
|
||||
command_buffer.run_ref(&pass);
|
||||
command_buffer.end_rendering();
|
||||
|
||||
@@ -13,7 +13,7 @@ use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
backend::{
|
||||
common::{OverlayContainer, OverlaySelector, TaskType},
|
||||
common::{OverlaySelector, TaskType},
|
||||
input::PointerMode,
|
||||
overlay::{OverlayData, OverlayState, RelativeTo},
|
||||
},
|
||||
|
||||
@@ -92,6 +92,10 @@ pub mod frag_srgb {
|
||||
layout (location = 0) out vec4 out_color;
|
||||
|
||||
layout (set = 0, binding = 0) uniform sampler2D in_texture;
|
||||
layout (set = 1, binding = 0) uniform AlphaBlock {
|
||||
uniform float alpha;
|
||||
};
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -102,6 +106,7 @@ pub mod frag_srgb {
|
||||
vec4 lower = out_color/vec4(12.92);
|
||||
|
||||
out_color = mix(higher, lower, cutoff);
|
||||
out_color.a = alpha;
|
||||
}
|
||||
",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user