summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/node.cpp10
-rw-r--r--scene/main/node.h2
-rw-r--r--scene/main/viewport.cpp96
-rw-r--r--scene/main/viewport.h28
-rw-r--r--scene/main/window.cpp5
-rw-r--r--scene/main/window.h1
6 files changed, 120 insertions, 22 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 44420fcc31..0d646ff2a9 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -114,7 +114,7 @@ void Node::_notification(int p_notification) {
get_multiplayer()->scene_enter_exit_notify(data.scene_file_path, this, false);
}
} break;
- case NOTIFICATION_PATH_CHANGED: {
+ case NOTIFICATION_PATH_RENAMED: {
if (data.path_cache) {
memdelete(data.path_cache);
data.path_cache = nullptr;
@@ -332,7 +332,7 @@ void Node::_move_child(Node *p_child, int p_pos, bool p_ignore_end) {
int motion_from = MIN(p_pos, p_child->data.pos);
int motion_to = MAX(p_pos, p_child->data.pos);
- data.children.remove(p_child->data.pos);
+ data.children.remove_at(p_child->data.pos);
data.children.insert(p_pos, p_child);
if (data.tree) {
@@ -899,7 +899,7 @@ void Node::set_name(const String &p_name) {
data.parent->_validate_child_name(this);
}
- propagate_notification(NOTIFICATION_PATH_CHANGED);
+ propagate_notification(NOTIFICATION_PATH_RENAMED);
if (is_inside_tree()) {
emit_signal(SNAME("renamed"));
@@ -1208,7 +1208,7 @@ void Node::remove_child(Node *p_child) {
remove_child_notify(p_child);
p_child->notification(NOTIFICATION_UNPARENTED);
- data.children.remove(idx);
+ data.children.remove_at(idx);
//update pointer and size
child_count = data.children.size();
@@ -2829,7 +2829,7 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_INSTANCED);
BIND_CONSTANT(NOTIFICATION_DRAG_BEGIN);
BIND_CONSTANT(NOTIFICATION_DRAG_END);
- BIND_CONSTANT(NOTIFICATION_PATH_CHANGED);
+ BIND_CONSTANT(NOTIFICATION_PATH_RENAMED);
BIND_CONSTANT(NOTIFICATION_INTERNAL_PROCESS);
BIND_CONSTANT(NOTIFICATION_INTERNAL_PHYSICS_PROCESS);
BIND_CONSTANT(NOTIFICATION_POST_ENTER_TREE);
diff --git a/scene/main/node.h b/scene/main/node.h
index 2dd32a2e1d..dc74a33580 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -256,7 +256,7 @@ public:
NOTIFICATION_INSTANCED = 20,
NOTIFICATION_DRAG_BEGIN = 21,
NOTIFICATION_DRAG_END = 22,
- NOTIFICATION_PATH_CHANGED = 23,
+ NOTIFICATION_PATH_RENAMED = 23,
//NOTIFICATION_TRANSLATION_CHANGED = 24, moved below
NOTIFICATION_INTERNAL_PROCESS = 25,
NOTIFICATION_INTERNAL_PHYSICS_PROCESS = 26,
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 48a672b310..f9e96a0784 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -55,6 +55,7 @@
#include "scene/resources/world_2d.h"
#include "scene/scene_string_names.h"
#include "servers/audio_server.h"
+#include "servers/rendering/rendering_server_globals.h"
void ViewportTexture::setup_local_to_scene() {
Node *local_scene = get_local_scene();
@@ -290,7 +291,7 @@ void Viewport::_sub_window_grab_focus(Window *p_window) {
if (p_window->get_flag(Window::FLAG_NO_FOCUS)) {
// Can only move to foreground, but no focus granted.
SubWindow sw = gui.sub_windows[index];
- gui.sub_windows.remove(index);
+ gui.sub_windows.remove_at(index);
gui.sub_windows.push_back(sw);
index = gui.sub_windows.size() - 1;
_sub_window_update_order();
@@ -318,7 +319,7 @@ void Viewport::_sub_window_grab_focus(Window *p_window) {
{ // Move to foreground.
SubWindow sw = gui.sub_windows[index];
- gui.sub_windows.remove(index);
+ gui.sub_windows.remove_at(index);
gui.sub_windows.push_back(sw);
index = gui.sub_windows.size() - 1;
_sub_window_update_order();
@@ -335,7 +336,7 @@ void Viewport::_sub_window_remove(Window *p_window) {
for (int i = 0; i < gui.sub_windows.size(); i++) {
if (gui.sub_windows[i].window == p_window) {
RS::get_singleton()->free(gui.sub_windows[i].canvas_item);
- gui.sub_windows.remove(i);
+ gui.sub_windows.remove_at(i);
break;
}
}
@@ -3473,17 +3474,60 @@ bool Viewport::is_using_xr() {
return use_xr;
}
-void Viewport::set_scale_3d(float p_scale_3d) {
+void Viewport::set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode) {
+ if (scaling_3d_mode == p_scaling_3d_mode) {
+ return;
+ }
+
+ scaling_3d_mode = p_scaling_3d_mode;
+ RS::get_singleton()->viewport_set_scaling_3d_mode(viewport, (RS::ViewportScaling3DMode)(int)p_scaling_3d_mode);
+}
+
+Viewport::Scaling3DMode Viewport::get_scaling_3d_mode() const {
+ return scaling_3d_mode;
+}
+
+void Viewport::set_scaling_3d_scale(float p_scaling_3d_scale) {
// Clamp to reasonable values that are actually useful.
// Values above 2.0 don't serve a practical purpose since the viewport
// isn't displayed with mipmaps.
- scale_3d = CLAMP(p_scale_3d, 0.1, 2.0);
+ scaling_3d_scale = CLAMP(p_scaling_3d_scale, 0.1, 2.0);
+
+ RS::get_singleton()->viewport_set_scaling_3d_scale(viewport, scaling_3d_scale);
+}
+
+float Viewport::get_scaling_3d_scale() const {
+ return scaling_3d_scale;
+}
+
+void Viewport::set_fsr_sharpness(float p_fsr_sharpness) {
+ if (fsr_sharpness == p_fsr_sharpness) {
+ return;
+ }
+
+ if (p_fsr_sharpness < 0.0f) {
+ p_fsr_sharpness = 0.0f;
+ }
- RS::get_singleton()->viewport_set_scale_3d(viewport, scale_3d);
+ fsr_sharpness = p_fsr_sharpness;
+ RS::get_singleton()->viewport_set_fsr_sharpness(viewport, p_fsr_sharpness);
}
-float Viewport::get_scale_3d() const {
- return scale_3d;
+float Viewport::get_fsr_sharpness() const {
+ return fsr_sharpness;
+}
+
+void Viewport::set_fsr_mipmap_bias(float p_fsr_mipmap_bias) {
+ if (fsr_mipmap_bias == p_fsr_mipmap_bias) {
+ return;
+ }
+
+ fsr_mipmap_bias = p_fsr_mipmap_bias;
+ RS::get_singleton()->viewport_set_fsr_mipmap_bias(viewport, p_fsr_mipmap_bias);
+}
+
+float Viewport::get_fsr_mipmap_bias() const {
+ return fsr_mipmap_bias;
}
#endif // _3D_DISABLED
@@ -3611,12 +3655,20 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_xr", "use"), &Viewport::set_use_xr);
ClassDB::bind_method(D_METHOD("is_using_xr"), &Viewport::is_using_xr);
- ClassDB::bind_method(D_METHOD("set_scale_3d", "scale"), &Viewport::set_scale_3d);
- ClassDB::bind_method(D_METHOD("get_scale_3d"), &Viewport::get_scale_3d);
+ ClassDB::bind_method(D_METHOD("set_scaling_3d_mode", "scaling_3d_mode"), &Viewport::set_scaling_3d_mode);
+ ClassDB::bind_method(D_METHOD("get_scaling_3d_mode"), &Viewport::get_scaling_3d_mode);
+
+ ClassDB::bind_method(D_METHOD("set_scaling_3d_scale", "scale"), &Viewport::set_scaling_3d_scale);
+ ClassDB::bind_method(D_METHOD("get_scaling_3d_scale"), &Viewport::get_scaling_3d_scale);
+
+ ClassDB::bind_method(D_METHOD("set_fsr_sharpness", "fsr_sharpness"), &Viewport::set_fsr_sharpness);
+ ClassDB::bind_method(D_METHOD("get_fsr_sharpness"), &Viewport::get_fsr_sharpness);
+
+ ClassDB::bind_method(D_METHOD("set_fsr_mipmap_bias", "fsr_mipmap_bias"), &Viewport::set_fsr_mipmap_bias);
+ ClassDB::bind_method(D_METHOD("get_fsr_mipmap_bias"), &Viewport::get_fsr_mipmap_bias);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_xr"), "set_use_xr", "is_using_xr");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scale_3d", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), "set_scale_3d", "get_scale_3d");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener_enable_3d"), "set_as_audio_listener_3d", "is_audio_listener_3d");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d");
@@ -3633,6 +3685,13 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_occlusion_culling"), "set_use_occlusion_culling", "is_using_occlusion_culling");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lod_threshold", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_lod_threshold", "get_lod_threshold");
ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw");
+#ifndef _3D_DISABLED
+ ADD_GROUP("Scaling 3D", "");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "scaling_3d_mode", PROPERTY_HINT_ENUM, "Disabled (Slowest),Bilinear (Fastest),FSR (Fast)"), "set_scaling_3d_mode", "get_scaling_3d_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scaling_3d_scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), "set_scaling_3d_scale", "get_scaling_3d_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fsr_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.1"), "set_fsr_mipmap_bias", "get_fsr_mipmap_bias");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), "set_fsr_sharpness", "get_fsr_sharpness");
+#endif
ADD_GROUP("Canvas Items", "canvas_item_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,Linear Mipmap,Nearest Mipmap"), "set_default_canvas_item_texture_filter", "get_default_canvas_item_texture_filter");
ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirror"), "set_default_canvas_item_texture_repeat", "get_default_canvas_item_texture_repeat");
@@ -3669,6 +3728,10 @@ void Viewport::_bind_methods() {
BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1024);
BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_MAX);
+ BIND_ENUM_CONSTANT(SCALING_3D_MODE_BILINEAR);
+ BIND_ENUM_CONSTANT(SCALING_3D_MODE_FSR);
+ BIND_ENUM_CONSTANT(SCALING_3D_MODE_MAX);
+
BIND_ENUM_CONSTANT(MSAA_DISABLED);
BIND_ENUM_CONSTANT(MSAA_2X);
BIND_ENUM_CONSTANT(MSAA_4X);
@@ -3772,7 +3835,16 @@ Viewport::Viewport() {
ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/tooltip_delay_sec", PropertyInfo(Variant::FLOAT, "gui/timers/tooltip_delay_sec", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); // No negative numbers
#ifndef _3D_DISABLED
- set_scale_3d(GLOBAL_GET("rendering/3d/viewport/scale"));
+ Viewport::Scaling3DMode scaling_3d_mode = (Viewport::Scaling3DMode)(int)GLOBAL_GET("rendering/scaling_3d/mode");
+ set_scaling_3d_mode(scaling_3d_mode);
+
+ set_scaling_3d_scale(GLOBAL_GET("rendering/scaling_3d/scale"));
+
+ float fsr_sharpness = GLOBAL_GET("rendering/scaling_3d/fsr_sharpness");
+ set_fsr_sharpness(fsr_sharpness);
+
+ float fsr_mipmap_bias = GLOBAL_GET("rendering/scaling_3d/fsr_mipmap_bias");
+ set_fsr_mipmap_bias(fsr_mipmap_bias);
#endif // _3D_DISABLED
set_sdf_oversize(sdf_oversize); // Set to server.
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 11b76b32eb..38d43e1e59 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -89,6 +89,12 @@ class Viewport : public Node {
GDCLASS(Viewport, Node);
public:
+ enum Scaling3DMode {
+ SCALING_3D_MODE_BILINEAR,
+ SCALING_3D_MODE_FSR,
+ SCALING_3D_MODE_MAX
+ };
+
enum ShadowAtlasQuadrantSubdiv {
SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED,
SHADOW_ATLAS_QUADRANT_SUBDIV_1,
@@ -284,6 +290,11 @@ private:
MSAA msaa = MSAA_DISABLED;
ScreenSpaceAA screen_space_aa = SCREEN_SPACE_AA_DISABLED;
+
+ Scaling3DMode scaling_3d_mode = SCALING_3D_MODE_BILINEAR;
+ float scaling_3d_scale = 1.0;
+ float fsr_sharpness = 0.2f;
+ float fsr_mipmap_bias = 0.0f;
bool use_debanding = false;
float lod_threshold = 1.0;
bool use_occlusion_culling = false;
@@ -504,6 +515,18 @@ public:
void set_screen_space_aa(ScreenSpaceAA p_screen_space_aa);
ScreenSpaceAA get_screen_space_aa() const;
+ void set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode);
+ Scaling3DMode get_scaling_3d_mode() const;
+
+ void set_scaling_3d_scale(float p_scaling_3d_scale);
+ float get_scaling_3d_scale() const;
+
+ void set_fsr_sharpness(float p_fsr_sharpness);
+ float get_fsr_sharpness() const;
+
+ void set_fsr_mipmap_bias(float p_fsr_mipmap_bias);
+ float get_fsr_mipmap_bias() const;
+
void set_use_debanding(bool p_use_debanding);
bool is_using_debanding() const;
@@ -586,7 +609,6 @@ public:
#ifndef _3D_DISABLED
bool use_xr = false;
- float scale_3d = 1.0;
friend class AudioListener3D;
AudioListener3D *audio_listener_3d = nullptr;
Set<AudioListener3D *> audio_listener_3d_set;
@@ -657,9 +679,6 @@ public:
void set_use_xr(bool p_use_xr);
bool is_using_xr();
-
- void set_scale_3d(float p_scale_3d);
- float get_scale_3d() const;
#endif // _3D_DISABLED
Viewport();
@@ -714,6 +733,7 @@ public:
SubViewport();
~SubViewport();
};
+VARIANT_ENUM_CAST(Viewport::Scaling3DMode);
VARIANT_ENUM_CAST(SubViewport::UpdateMode);
VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv);
VARIANT_ENUM_CAST(Viewport::MSAA);
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index 5da5a183f7..20f8b30dc6 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -88,6 +88,10 @@ Size2i Window::get_size() const {
return size;
}
+void Window::reset_size() {
+ set_size(Size2i());
+}
+
Size2i Window::get_real_size() const {
if (window_id != DisplayServer::INVALID_WINDOW_ID) {
return DisplayServer::get_singleton()->window_get_real_size(window_id);
@@ -1410,6 +1414,7 @@ void Window::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_size", "size"), &Window::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &Window::get_size);
+ ClassDB::bind_method(D_METHOD("reset_size"), &Window::reset_size);
ClassDB::bind_method(D_METHOD("get_real_size"), &Window::get_real_size);
diff --git a/scene/main/window.h b/scene/main/window.h
index def6eab7b8..0b1075ff76 100644
--- a/scene/main/window.h
+++ b/scene/main/window.h
@@ -178,6 +178,7 @@ public:
void set_size(const Size2i &p_size);
Size2i get_size() const;
+ void reset_size();
Size2i get_real_size() const;