diff options
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/scene_tree.cpp | 4 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 25 | ||||
-rw-r--r-- | scene/main/viewport.h | 8 |
3 files changed, 31 insertions, 6 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 9e396d4030..1df61daa2c 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1391,6 +1391,10 @@ SceneTree::SceneTree() { const bool use_debanding = GLOBAL_DEF("rendering/quality/screen_filters/use_debanding", false); root->set_use_debanding(use_debanding); + float lod_threshold = GLOBAL_DEF("rendering/quality/mesh_lod/threshold_pixels", 1.0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/mesh_lod/threshold_pixels", PropertyInfo(Variant::FLOAT, "rendering/quality/mesh_lod/threshold_pixels", PROPERTY_HINT_RANGE, "0,1024,0.1")); + root->set_lod_threshold(lod_threshold); + bool snap_2d_transforms = GLOBAL_DEF("rendering/quality/2d/snap_2d_transforms_to_pixel", false); root->set_snap_2d_transforms_to_pixel(snap_2d_transforms); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 6350777a3d..c96dd4ad35 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2392,19 +2392,19 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } if (!mods && p_event->is_action_pressed("ui_up") && input->is_action_just_pressed("ui_up")) { - next = from->_get_focus_neighbour(MARGIN_TOP); + next = from->_get_focus_neighbor(MARGIN_TOP); } if (!mods && p_event->is_action_pressed("ui_left") && input->is_action_just_pressed("ui_left")) { - next = from->_get_focus_neighbour(MARGIN_LEFT); + next = from->_get_focus_neighbor(MARGIN_LEFT); } if (!mods && p_event->is_action_pressed("ui_right") && input->is_action_just_pressed("ui_right")) { - next = from->_get_focus_neighbour(MARGIN_RIGHT); + next = from->_get_focus_neighbor(MARGIN_RIGHT); } if (!mods && p_event->is_action_pressed("ui_down") && input->is_action_just_pressed("ui_down")) { - next = from->_get_focus_neighbour(MARGIN_BOTTOM); + next = from->_get_focus_neighbor(MARGIN_BOTTOM); } if (next) { @@ -3192,6 +3192,14 @@ bool Viewport::is_using_debanding() const { return use_debanding; } +void Viewport::set_lod_threshold(float p_pixels) { + lod_threshold = p_pixels; + RS::get_singleton()->viewport_set_lod_threshold(viewport, lod_threshold); +} +float Viewport::get_lod_threshold() const { + return lod_threshold; +} + void Viewport::set_debug_draw(DebugDraw p_debug_draw) { debug_draw = p_debug_draw; RS::get_singleton()->viewport_set_debug_draw(viewport, RS::ViewportDebugDraw(p_debug_draw)); @@ -3505,6 +3513,9 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sdf_scale", "scale"), &Viewport::set_sdf_scale); ClassDB::bind_method(D_METHOD("get_sdf_scale"), &Viewport::get_sdf_scale); + ClassDB::bind_method(D_METHOD("set_lod_threshold", "pixels"), &Viewport::set_lod_threshold); + ClassDB::bind_method(D_METHOD("get_lod_threshold"), &Viewport::get_lod_threshold); + 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"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d"); @@ -3516,6 +3527,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x"), "set_msaa", "get_msaa"); ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_space_aa", PROPERTY_HINT_ENUM, "Disabled,FXAA"), "set_screen_space_aa", "get_screen_space_aa"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_debanding"), "set_use_debanding", "is_using_debanding"); + 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"); ADD_GROUP("Canvas Items", "canvas_item_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,MipmapLinear,MipmapNearest"), "set_default_canvas_item_texture_filter", "get_default_canvas_item_texture_filter"); @@ -3590,6 +3602,7 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(DEBUG_DRAW_SDFGI); BIND_ENUM_CONSTANT(DEBUG_DRAW_SDFGI_PROBES); BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_BUFFER); + BIND_ENUM_CONSTANT(DEBUG_DRAW_DISABLE_LOD); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR); @@ -3652,6 +3665,8 @@ Viewport::Viewport() { set_shadow_atlas_quadrant_subdiv(2, SHADOW_ATLAS_QUADRANT_SUBDIV_16); set_shadow_atlas_quadrant_subdiv(3, SHADOW_ATLAS_QUADRANT_SUBDIV_64); + set_lod_threshold(lod_threshold); + String id = itos(get_instance_id()); input_group = "_vp_input" + id; gui_input_group = "_vp_gui_input" + id; @@ -3824,7 +3839,7 @@ void SubViewport::_bind_methods() { BIND_ENUM_CONSTANT(CLEAR_MODE_ALWAYS); BIND_ENUM_CONSTANT(CLEAR_MODE_NEVER); - BIND_ENUM_CONSTANT(CLEAR_MODE_ONLY_NEXT_FRAME); + BIND_ENUM_CONSTANT(CLEAR_MODE_ONCE); BIND_ENUM_CONSTANT(UPDATE_DISABLED); BIND_ENUM_CONSTANT(UPDATE_ONCE); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 7ce202d27c..ffbc3c782a 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -142,6 +142,7 @@ public: DEBUG_DRAW_SDFGI, DEBUG_DRAW_SDFGI_PROBES, DEBUG_DRAW_GI_BUFFER, + DEBUG_DRAW_DISABLE_LOD, }; enum DefaultCanvasItemTextureFilter { @@ -297,6 +298,8 @@ private: MSAA msaa; ScreenSpaceAA screen_space_aa; bool use_debanding = false; + float lod_threshold = 1.0; + Ref<ViewportTexture> default_texture; Set<ViewportTexture *> viewport_textures; @@ -542,6 +545,9 @@ public: void set_use_debanding(bool p_use_debanding); bool is_using_debanding() const; + void set_lod_threshold(float p_pixels); + float get_lod_threshold() const; + Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const; Vector2 get_camera_rect_size() const; @@ -624,7 +630,7 @@ public: enum ClearMode { CLEAR_MODE_ALWAYS, CLEAR_MODE_NEVER, - CLEAR_MODE_ONLY_NEXT_FRAME + CLEAR_MODE_ONCE }; enum UpdateMode { |