diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index fb44839d..e5167c29 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -536,6 +536,17 @@ static std::vector render_layer(std::vector +struct overloaded : Ts... +{ + using Ts::operator()...; +}; +template +overloaded(Ts...) -> overloaded; +} // namespace + void scenes::lobby::render(XrTime predicted_display_time, bool should_render) { if (async_session.valid() && async_session.poll() == utils::future_status::ready) @@ -653,14 +664,19 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render) .views = controllers_layer_views.data(), }; + XrEnvironmentBlendMode blend_mode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE; std::vector layers_base; if (passthrough_enabled) { std::visit( - [&](auto & p) { - layers_base.push_back(p.layer()); - }, + overloaded{ + [&](xr::passthrough_alpha_blend & p) { + blend_mode = XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND; + }, + [&](auto & p) { + layers_base.push_back(p.layer()); + }}, passthrough); } else @@ -670,7 +686,7 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render) layers_base.push_back(reinterpret_cast(&imgui_layer)); layers_base.push_back(reinterpret_cast(&controllers_layer)); - session.end_frame(predicted_display_time, layers_base); + session.end_frame(predicted_display_time, layers_base, blend_mode); } void scenes::lobby::on_focused() @@ -749,7 +765,11 @@ void scenes::lobby::on_focused() if (passthrough_supported != xr::system::passthrough_type::no_passthrough) { - if (utils::contains(application::get_xr_extensions(), XR_FB_PASSTHROUGH_EXTENSION_NAME)) + if (utils::contains(system.environment_blend_modes(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO), XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND)) + { + passthrough.emplace(); + } + else if (utils::contains(application::get_xr_extensions(), XR_FB_PASSTHROUGH_EXTENSION_NAME)) { passthrough.emplace(instance, session); } diff --git a/client/xr/passthrough.h b/client/xr/passthrough.h index 8b9682b5..f224917c 100644 --- a/client/xr/passthrough.h +++ b/client/xr/passthrough.h @@ -91,6 +91,13 @@ public: } }; -using passthrough = std::variant; +class passthrough_alpha_blend +{ +public: + void start() {} + void pause() {} +}; + +using passthrough = std::variant; } // namespace xr diff --git a/client/xr/system.cpp b/client/xr/system.cpp index 72c1192a..b7e6ffe9 100644 --- a/client/xr/system.cpp +++ b/client/xr/system.cpp @@ -89,6 +89,9 @@ XrSystemHandTrackingPropertiesEXT xr::system::hand_tracking_properties() const xr::system::passthrough_type xr::system::passthrough_supported() const { + if (utils::contains(environment_blend_modes(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO), XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND)) + return passthrough_type::color; + const std::vector & xr_extensions = application::get_xr_extensions(); if (utils::contains(xr_extensions, XR_HTC_PASSTHROUGH_EXTENSION_NAME)) return passthrough_type::color;