summaryrefslogtreecommitdiffstats
path: root/modules/openxr/openxr_interface.cpp
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2024-03-26 12:57:26 +1100
committerBastiaan Olij <mux213@gmail.com>2024-05-03 17:20:30 +1000
commit9042ddf19f33445abbb69a8330fff7e98fcda2dc (patch)
tree6e3fc77e57d3b032d525e9d02dd753cc99ac65af /modules/openxr/openxr_interface.cpp
parent34b5e8f55cb7d09977074b1486bbdf00d5c16a01 (diff)
downloadredot-engine-9042ddf19f33445abbb69a8330fff7e98fcda2dc.tar.gz
Improvements to VRS/Foveated rendering
Diffstat (limited to 'modules/openxr/openxr_interface.cpp')
-rw-r--r--modules/openxr/openxr_interface.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp
index 39a61d1b4d..b92d1edb90 100644
--- a/modules/openxr/openxr_interface.cpp
+++ b/modules/openxr/openxr_interface.cpp
@@ -97,6 +97,16 @@ void OpenXRInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_hand_interaction_supported"), &OpenXRInterface::is_hand_interaction_supported);
ClassDB::bind_method(D_METHOD("is_eye_gaze_interaction_supported"), &OpenXRInterface::is_eye_gaze_interaction_supported);
+ // VRS
+ ClassDB::bind_method(D_METHOD("get_vrs_min_radius"), &OpenXRInterface::get_vrs_min_radius);
+ ClassDB::bind_method(D_METHOD("set_vrs_min_radius", "radius"), &OpenXRInterface::set_vrs_min_radius);
+ ClassDB::bind_method(D_METHOD("get_vrs_strength"), &OpenXRInterface::get_vrs_strength);
+ ClassDB::bind_method(D_METHOD("set_vrs_strength", "strength"), &OpenXRInterface::set_vrs_strength);
+
+ ADD_GROUP("Vulkan VRS", "vrs_");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "vrs_min_radius", PROPERTY_HINT_RANGE, "1.0,100.0,1.0"), "set_vrs_min_radius", "get_vrs_min_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "vrs_strength", PROPERTY_HINT_RANGE, "0.1,10.0,0.1"), "set_vrs_strength", "get_vrs_strength");
+
BIND_ENUM_CONSTANT(HAND_LEFT);
BIND_ENUM_CONSTANT(HAND_RIGHT);
BIND_ENUM_CONSTANT(HAND_MAX);
@@ -872,6 +882,22 @@ Array OpenXRInterface::get_action_sets() const {
return arr;
}
+float OpenXRInterface::get_vrs_min_radius() const {
+ return xr_vrs.get_vrs_min_radius();
+}
+
+void OpenXRInterface::set_vrs_min_radius(float p_vrs_min_radius) {
+ xr_vrs.set_vrs_min_radius(p_vrs_min_radius);
+}
+
+float OpenXRInterface::get_vrs_strength() const {
+ return xr_vrs.get_vrs_strength();
+}
+
+void OpenXRInterface::set_vrs_strength(float p_vrs_strength) {
+ xr_vrs.set_vrs_strength(p_vrs_strength);
+}
+
double OpenXRInterface::get_render_target_size_multiplier() const {
if (openxr_api == nullptr) {
return 1.0;
@@ -1435,6 +1461,24 @@ Vector3 OpenXRInterface::get_hand_joint_angular_velocity(Hand p_hand, HandJoints
return Vector3();
}
+RID OpenXRInterface::get_vrs_texture() {
+ if (!openxr_api) {
+ return RID();
+ }
+
+ PackedVector2Array eye_foci;
+
+ Size2 target_size = get_render_target_size();
+ real_t aspect_ratio = target_size.x / target_size.y;
+ uint32_t view_count = get_view_count();
+
+ for (uint32_t v = 0; v < view_count; v++) {
+ eye_foci.push_back(openxr_api->get_eye_focus(v, aspect_ratio));
+ }
+
+ return xr_vrs.make_vrs_texture(target_size, eye_foci);
+}
+
OpenXRInterface::OpenXRInterface() {
openxr_api = OpenXRAPI::get_singleton();
if (openxr_api) {