diff --git a/doc/classes/RenderSceneData.xml b/doc/classes/RenderSceneData.xml
index 0ac13ca6d84f25..84e5eeb3dc879b 100644
--- a/doc/classes/RenderSceneData.xml
+++ b/doc/classes/RenderSceneData.xml
@@ -12,9 +12,11 @@
+
Returns the camera projection used to render this frame.
[b]Note:[/b] If more than one view is rendered, this will return a combined projection.
+ [param flip_y] should be true for viewports rendered with Rendering Device based renderers, false for reflection probes and the compatibility renderer.
@@ -46,9 +48,11 @@
+
Returns the view projection per view used to render this frame.
[b]Note:[/b] If a single view is rendered, this returns the camera projection. If more than one view is rendered, this will return a projection for the given view including the eye offset.
+ [param flip_y] should be true for viewports rendered with Rendering Device based renderers, false for reflection probes and the compatibility renderer.
diff --git a/doc/classes/RenderSceneDataExtension.xml b/doc/classes/RenderSceneDataExtension.xml
index 72eb7fc54dcfb4..6e1107a1a48c93 100644
--- a/doc/classes/RenderSceneDataExtension.xml
+++ b/doc/classes/RenderSceneDataExtension.xml
@@ -11,6 +11,7 @@
+
Implement this in GDExtension to return the camera [Projection].
@@ -43,6 +44,7 @@
+
Implement this in GDExtension to return the view [Projection] for the given [param view].
diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.cpp b/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.cpp
index dc1e64ddcc218e..d4be9b350c22fd 100644
--- a/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.cpp
@@ -41,8 +41,12 @@ Transform3D RenderSceneDataRD::get_cam_transform() const {
return cam_transform;
}
-Projection RenderSceneDataRD::get_cam_projection() const {
- return cam_projection;
+Projection RenderSceneDataRD::get_cam_projection(bool p_flip_y) const {
+ Projection correction;
+ correction.set_depth_correction(p_flip_y);
+ correction.add_jitter_offset(taa_jitter);
+
+ return correction * cam_projection;
}
uint32_t RenderSceneDataRD::get_view_count() const {
@@ -55,10 +59,14 @@ Vector3 RenderSceneDataRD::get_view_eye_offset(uint32_t p_view) const {
return view_eye_offset[p_view];
}
-Projection RenderSceneDataRD::get_view_projection(uint32_t p_view) const {
+Projection RenderSceneDataRD::get_view_projection(uint32_t p_view, bool p_flip_y) const {
ERR_FAIL_UNSIGNED_INDEX_V(p_view, view_count, Projection());
- return view_projection[p_view];
+ Projection correction;
+ correction.set_depth_correction(p_flip_y);
+ correction.add_jitter_offset(taa_jitter);
+
+ return correction * view_projection[p_view];
}
RID RenderSceneDataRD::create_uniform_buffer() {
diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.h b/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.h
index f6785942edb147..989deb39e51961 100644
--- a/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.h
+++ b/servers/rendering/renderer_rd/storage_rd/render_scene_data_rd.h
@@ -83,11 +83,11 @@ class RenderSceneDataRD : public RenderSceneData {
float time_step;
virtual Transform3D get_cam_transform() const override;
- virtual Projection get_cam_projection() const override;
+ virtual Projection get_cam_projection(bool p_flip_y = true) const override;
virtual uint32_t get_view_count() const override;
virtual Vector3 get_view_eye_offset(uint32_t p_view) const override;
- virtual Projection get_view_projection(uint32_t p_view) const override;
+ virtual Projection get_view_projection(uint32_t p_view, bool p_flip_y = true) const override;
RID create_uniform_buffer();
void update_ubo(RID p_uniform_buffer, RS::ViewportDebugDraw p_debug_mode, RID p_env, RID p_reflection_probe_instance, RID p_camera_attributes, bool p_flip_y, bool p_pancake_shadows, const Size2i &p_screen_size, const Color &p_default_bg_color, float p_luminance_multiplier, bool p_opaque_render_buffers, bool p_apply_alpha_multiplier);
diff --git a/servers/rendering/storage/render_scene_data.compat.inc b/servers/rendering/storage/render_scene_data.compat.inc
new file mode 100644
index 00000000000000..71a511903cc6b6
--- /dev/null
+++ b/servers/rendering/storage/render_scene_data.compat.inc
@@ -0,0 +1,46 @@
+/**************************************************************************/
+/* render_scene_data.compat.inc */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef DISABLE_DEPRECATED
+
+Projection RenderSceneData::_get_cam_projection_bind_compat_93630() {
+ return get_cam_projection(true);
+}
+
+Projection RenderSceneData::_get_view_projection_bind_compat_93630(uint32_t p_view) {
+ return get_view_projection(p_view, true);
+}
+
+void RenderSceneData::_bind_compatibility_methods() {
+ ClassDB::bind_compatibility_method(D_METHOD("get_cam_projection"), &RenderSceneData::_get_cam_projection_bind_compat_93630);
+ ClassDB::bind_compatibility_method(D_METHOD("get_view_projection", "view"), &RenderSceneData::_get_view_projection_bind_compat_93630);
+}
+
+#endif // DISABLE_DEPRECATED
diff --git a/servers/rendering/storage/render_scene_data.cpp b/servers/rendering/storage/render_scene_data.cpp
index a1d8f524b431cb..56d71e9e7eab81 100644
--- a/servers/rendering/storage/render_scene_data.cpp
+++ b/servers/rendering/storage/render_scene_data.cpp
@@ -29,24 +29,25 @@
/**************************************************************************/
#include "render_scene_data.h"
+#include "render_scene_data.compat.inc"
void RenderSceneData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_cam_transform"), &RenderSceneData::get_cam_transform);
- ClassDB::bind_method(D_METHOD("get_cam_projection"), &RenderSceneData::get_cam_projection);
+ ClassDB::bind_method(D_METHOD("get_cam_projection", "flip_y"), &RenderSceneData::get_cam_projection, DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_view_count"), &RenderSceneData::get_view_count);
ClassDB::bind_method(D_METHOD("get_view_eye_offset", "view"), &RenderSceneData::get_view_eye_offset);
- ClassDB::bind_method(D_METHOD("get_view_projection", "view"), &RenderSceneData::get_view_projection);
+ ClassDB::bind_method(D_METHOD("get_view_projection", "view", "flip_y"), &RenderSceneData::get_view_projection, DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_uniform_buffer"), &RenderSceneData::get_uniform_buffer);
}
void RenderSceneDataExtension::_bind_methods() {
GDVIRTUAL_BIND(_get_cam_transform);
- GDVIRTUAL_BIND(_get_cam_projection);
+ GDVIRTUAL_BIND(_get_cam_projection, "flip_y");
GDVIRTUAL_BIND(_get_view_count);
GDVIRTUAL_BIND(_get_view_eye_offset, "view");
- GDVIRTUAL_BIND(_get_view_projection, "view");
+ GDVIRTUAL_BIND(_get_view_projection, "view", "flip_y");
GDVIRTUAL_BIND(_get_uniform_buffer);
}
@@ -57,9 +58,9 @@ Transform3D RenderSceneDataExtension::get_cam_transform() const {
return ret;
}
-Projection RenderSceneDataExtension::get_cam_projection() const {
+Projection RenderSceneDataExtension::get_cam_projection(bool p_flip_y) const {
Projection ret;
- GDVIRTUAL_CALL(_get_cam_projection, ret);
+ GDVIRTUAL_CALL(_get_cam_projection, p_flip_y, ret);
return ret;
}
@@ -75,9 +76,9 @@ Vector3 RenderSceneDataExtension::get_view_eye_offset(uint32_t p_view) const {
return ret;
}
-Projection RenderSceneDataExtension::get_view_projection(uint32_t p_view) const {
+Projection RenderSceneDataExtension::get_view_projection(uint32_t p_view, bool p_flip_y) const {
Projection ret;
- GDVIRTUAL_CALL(_get_view_projection, p_view, ret);
+ GDVIRTUAL_CALL(_get_view_projection, p_view, p_flip_y, ret);
return ret;
}
diff --git a/servers/rendering/storage/render_scene_data.h b/servers/rendering/storage/render_scene_data.h
index 6a00cecc967718..01c4d803fbd8f2 100644
--- a/servers/rendering/storage/render_scene_data.h
+++ b/servers/rendering/storage/render_scene_data.h
@@ -42,13 +42,21 @@ class RenderSceneData : public Object {
protected:
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+
+ Projection _get_cam_projection_bind_compat_93630();
+ Projection _get_view_projection_bind_compat_93630(uint32_t p_view);
+ static void _bind_compatibility_methods();
+
+#endif // DISABLE_DEPRECATED
+
public:
virtual Transform3D get_cam_transform() const = 0;
- virtual Projection get_cam_projection() const = 0;
+ virtual Projection get_cam_projection(bool p_flip_y = true) const = 0;
virtual uint32_t get_view_count() const = 0;
virtual Vector3 get_view_eye_offset(uint32_t p_view) const = 0;
- virtual Projection get_view_projection(uint32_t p_view) const = 0;
+ virtual Projection get_view_projection(uint32_t p_view, bool p_flip_y = true) const = 0;
virtual RID get_uniform_buffer() const = 0;
};
@@ -61,20 +69,20 @@ class RenderSceneDataExtension : public RenderSceneData {
public:
virtual Transform3D get_cam_transform() const override;
- virtual Projection get_cam_projection() const override;
+ virtual Projection get_cam_projection(bool p_flip_y = true) const override;
virtual uint32_t get_view_count() const override;
virtual Vector3 get_view_eye_offset(uint32_t p_view) const override;
- virtual Projection get_view_projection(uint32_t p_view) const override;
+ virtual Projection get_view_projection(uint32_t p_view, bool p_flip_y = true) const override;
virtual RID get_uniform_buffer() const override;
GDVIRTUAL0RC(Transform3D, _get_cam_transform)
- GDVIRTUAL0RC(Projection, _get_cam_projection)
+ GDVIRTUAL1RC(Projection, _get_cam_projection, bool)
GDVIRTUAL0RC(uint32_t, _get_view_count)
GDVIRTUAL1RC(Vector3, _get_view_eye_offset, uint32_t)
- GDVIRTUAL1RC(Projection, _get_view_projection, uint32_t)
+ GDVIRTUAL2RC(Projection, _get_view_projection, uint32_t, bool)
GDVIRTUAL0RC(RID, _get_uniform_buffer)
};