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..5a29dd521ab4c3 --- /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_12345() { + return get_cam_projection(true); +} + +Projection RenderSceneData::_get_view_projection_12345(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_12345); + ClassDB::bind_compatibility_method(D_METHOD("get_view_projection", "view"), &RenderSceneData::_get_view_projection_12345); +} + +#endif // DISABLE_DEPRECATED diff --git a/servers/rendering/storage/render_scene_data.cpp b/servers/rendering/storage/render_scene_data.cpp index a1d8f524b431cb..d1ed09c937bb57 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); 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..d67d8a282cbe2a 100644 --- a/servers/rendering/storage/render_scene_data.h +++ b/servers/rendering/storage/render_scene_data.h @@ -42,13 +42,22 @@ class RenderSceneData : public Object { protected: static void _bind_methods(); +#ifndef DISABLE_DEPRECATED + + Projection _get_cam_projection_12345(); + Projection _get_view_projection_12345(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 +70,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) };