Skip to content

Commit de60471

Browse files
authored
Merge pull request #450 from openglfreak/feat-grid-opacity
add option for grid opacity
2 parents b517afc + 39152b8 commit de60471

File tree

7 files changed

+25
-2
lines changed

7 files changed

+25
-2
lines changed

dash-frontend/assets/lang/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@
107107
"USE_PASSTHROUGH_HELP": "Allow passthrough if the XR runtime supports it",
108108
"USE_SKYBOX": "Enable skybox",
109109
"USE_SKYBOX_HELP": "Show a skybox if there's no scene app or passthrough",
110+
"GRID_OPACITY": "Skybox grid opacity",
111+
"GRID_OPACITY_HELP": "Opacity of the floor grid when the skybox is enabled",
110112
"XR_CLICK_SENSITIVITY": "XR click sensitivity",
111113
"XR_CLICK_SENSITIVITY_HELP": "Analog trigger sensitivity",
112114
"XR_CLICK_SENSITIVITY_RELEASE": "XR release sensitivity",

dash-frontend/src/tab/settings.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ enum SettingType {
247247
UprightScreenFix,
248248
UsePassthrough,
249249
UseSkybox,
250+
GridOpacity,
250251
XrClickSensitivity,
251252
XrClickSensitivityRelease,
252253
XwaylandByDefault,
@@ -294,6 +295,7 @@ impl SettingType {
294295
Self::XrClickSensitivityRelease => &mut config.xr_click_sensitivity_release,
295296
Self::SpaceDragMultiplier => &mut config.space_drag_multiplier,
296297
Self::PointerLerpFactor => &mut config.pointer_lerp_factor,
298+
Self::GridOpacity => &mut config.grid_opacity,
297299
_ => panic!("Requested f32 for non-f32 SettingType"),
298300
}
299301
}
@@ -368,6 +370,7 @@ impl SettingType {
368370
Self::Clock12h => Ok("APP_SETTINGS.CLOCK_12H"),
369371
Self::DoubleCursorFix => Ok("APP_SETTINGS.DOUBLE_CURSOR_FIX"),
370372
Self::FocusFollowsMouseMode => Ok("APP_SETTINGS.FOCUS_FOLLOWS_MOUSE_MODE"),
373+
Self::GridOpacity => Ok("APP_SETTINGS.GRID_OPACITY"),
371374
Self::HandsfreePointer => Ok("APP_SETTINGS.HANDSFREE_POINTER"),
372375
Self::HideGrabHelp => Ok("APP_SETTINGS.HIDE_GRAB_HELP"),
373376
Self::HideUsername => Ok("APP_SETTINGS.HIDE_USERNAME"),
@@ -408,6 +411,7 @@ impl SettingType {
408411
Self::BlockPosesOnKbdInteraction => Some("APP_SETTINGS.BLOCK_POSES_ON_KBD_INTERACTION_HELP"),
409412
Self::CaptureMethod => Some("APP_SETTINGS.CAPTURE_METHOD_HELP"),
410413
Self::DoubleCursorFix => Some("APP_SETTINGS.DOUBLE_CURSOR_FIX_HELP"),
414+
Self::GridOpacity => Some("APP_SETTINGS.GRID_OPACITY_HELP"),
411415
Self::HandsfreePointer => Some("APP_SETTINGS.HANDSFREE_POINTER_HELP"),
412416
Self::KeyboardMiddleClick => Some("APP_SETTINGS.KEYBOARD_MIDDLE_CLICK_HELP"),
413417
Self::LeftHandedMouse => Some("APP_SETTINGS.LEFT_HANDED_MOUSE_HELP"),
@@ -795,6 +799,7 @@ impl<T> TabSettings<T> {
795799
slider_f32!(mp, c, SettingType::UiRoundMultiplier, 0.5, 5.0, 0.1);
796800
checkbox!(mp, c, SettingType::SetsOnWatch);
797801
checkbox!(mp, c, SettingType::UseSkybox);
802+
slider_f32!(mp, c, SettingType::GridOpacity, 0.0, 1.0, 0.05); // min, max, step
798803
checkbox!(mp, c, SettingType::UsePassthrough);
799804
checkbox!(mp, c, SettingType::Clock12h);
800805
}

wayvr/src/backend/openxr/skybox.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,17 @@ impl Skybox {
161161
.into_iter()
162162
.next()
163163
.unwrap();
164+
let set0 = pipeline.uniform_buffer_upload(
165+
0,
166+
vec![app.session.config.grid_opacity * app.session.config.grid_opacity],
167+
)?;
164168
let pass = pipeline.create_pass(
165169
tgt.extent_f32(),
166170
[0.0, 0.0],
167171
app.gfx_extras.quad_verts.clone(),
168172
0..4,
169173
0..1,
170-
vec![],
174+
vec![set0],
171175
&Default::default(),
172176
)?;
173177

wayvr/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub struct AutoSettings {
130130
pub block_poses_on_kbd_interaction: bool,
131131
pub space_drag_multiplier: f32,
132132
pub use_skybox: bool,
133+
pub grid_opacity: f32,
133134
pub use_passthrough: bool,
134135
pub screen_render_down: bool,
135136
pub pointer_lerp_factor: f32,
@@ -180,6 +181,7 @@ pub fn save_settings(config: &GeneralConfig) -> anyhow::Result<()> {
180181
block_poses_on_kbd_interaction: config.block_poses_on_kbd_interaction,
181182
space_drag_multiplier: config.space_drag_multiplier,
182183
use_skybox: config.use_skybox,
184+
grid_opacity: config.grid_opacity,
183185
use_passthrough: config.use_passthrough,
184186
screen_render_down: config.screen_render_down,
185187
pointer_lerp_factor: config.pointer_lerp_factor,

wayvr/src/res/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
## If disabled, there will be no background rendered (solid black).
126126
#use_skybox: true
127127

128+
## Monado/WiVRn only. Opacity of the floor grid if use_skybox is enabled.
129+
#grid_opacity: true
130+
128131
## Hide the help popup that appears on your hand while grabbing an overlay
129132
#hide_grab_help: false
130133

wayvr/src/shaders/grid.frag

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ precision highp float;
44
layout (location = 0) in vec2 in_uv;
55
layout (location = 0) out vec4 out_color;
66

7+
layout (set = 0, binding = 0) uniform OpacityBlock {
8+
uniform float opacity;
9+
};
10+
711
void main()
812
{
913
float fade = max(1.0 - 2.0 * length(in_uv.xy + vec2(-0.5, -0.5)), 0.0);
@@ -14,6 +18,6 @@ void main()
1418
} else {
1519
grid = 0.0;
1620
}
17-
out_color = vec4(1.0, 1.0, 1.0, grid * fade);
21+
out_color = vec4(1.0, 1.0, 1.0, grid * fade * opacity);
1822
}
1923

wlx-common/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,7 @@ pub struct GeneralConfig {
324324

325325
#[serde(default)]
326326
pub handsfree_pointer: HandsfreePointer,
327+
328+
#[serde(default = "def_one")]
329+
pub grid_opacity: f32,
327330
}

0 commit comments

Comments
 (0)