Skip to content

Commit c054b60

Browse files
committed
Rework how the 3D editor viewport's resolution scale is changed
- Removed the Half Resolution per-viewport setting in favor of an editor setting that applies to all 3D viewports in all projects. - Use an automatic rendering scale by default that's set to 100% on loDPI displays and 50% on hiDPI displays (editor scale >= 1.667). - Add 25% and 33% scaling options in the Editor Settings. This is useful for low-end hardware with hiDPI displays (such as 4K laptops). The rendering scale is updated when the editor setting changes, so no restart is required to apply rendering scale changes (as before).
1 parent 758bccf commit c054b60

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

editor/editor_settings.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
641641
hints["editors/3d/default_z_near"] = PropertyInfo(Variant::FLOAT, "editors/3d/default_z_near", PROPERTY_HINT_RANGE, "0.01,10,0.01,or_greater");
642642
_initial_set("editors/3d/default_z_far", 4000.0);
643643
hints["editors/3d/default_z_far"] = PropertyInfo(Variant::FLOAT, "editors/3d/default_z_far", PROPERTY_HINT_RANGE, "0.1,4000,0.1,or_greater");
644+
_initial_set("editors/3d/viewport_resolution_scale", 0);
645+
hints["editors/3d/viewport_resolution_scale"] = PropertyInfo(Variant::INT, "editors/3d/viewport_resolution_scale", PROPERTY_HINT_ENUM, "Auto (DPI-specific),Very Low (25%),Low (33%),Medium (50%),Full (100%)");
644646

645647
// 3D: Navigation
646648
_initial_set("editors/3d/navigation/navigation_scheme", 0);

editor/plugins/node_3d_editor_plugin.cpp

+26-19
Original file line numberDiff line numberDiff line change
@@ -2354,12 +2354,34 @@ void Node3DEditorViewport::_project_settings_changed() {
23542354
viewport->set_shadow_atlas_quadrant_subdiv(2, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q2));
23552355
viewport->set_shadow_atlas_quadrant_subdiv(3, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q3));
23562356

2357-
bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));
2358-
2359-
if (shrink != (subviewport_container->get_stretch_shrink() > 1)) {
2360-
subviewport_container->set_stretch_shrink(shrink ? 2 : 1);
2357+
int shrink_factor;
2358+
switch (int(EDITOR_GET("editors/3d/viewport_resolution_scale"))) {
2359+
case 0:
2360+
// Auto (DPI-specific).
2361+
// Use 1:2 render scale on hiDPI displays to improve performance, especially on integrated graphics.
2362+
shrink_factor = EDSCALE >= 1.667 ? 2 : 1;
2363+
break;
2364+
case 1:
2365+
// Very Low (1:4).
2366+
shrink_factor = 4;
2367+
break;
2368+
case 2:
2369+
// Low (1:3).
2370+
shrink_factor = 3;
2371+
break;
2372+
case 3:
2373+
// Medium (1:2).
2374+
shrink_factor = 2;
2375+
break;
2376+
case 4:
2377+
default:
2378+
// Full (1:1).
2379+
shrink_factor = 1;
2380+
break;
23612381
}
23622382

2383+
subviewport_container->set_stretch_shrink(shrink_factor);
2384+
23632385
// Update MSAA, screen-space AA and debanding if changed
23642386

23652387
const int msaa_mode = ProjectSettings::get_singleton()->get("rendering/anti_aliasing/quality/msaa");
@@ -3034,12 +3056,6 @@ void Node3DEditorViewport::_menu_option(int p_option) {
30343056
view_menu->get_popup()->set_item_checked(idx, current);
30353057

30363058
} break;
3037-
case VIEW_HALF_RESOLUTION: {
3038-
int idx = view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION);
3039-
bool current = view_menu->get_popup()->is_item_checked(idx);
3040-
current = !current;
3041-
view_menu->get_popup()->set_item_checked(idx, current);
3042-
} break;
30433059
case VIEW_INFORMATION: {
30443060
int idx = view_menu->get_popup()->get_item_index(VIEW_INFORMATION);
30453061
bool current = view_menu->get_popup()->is_item_checked(idx);
@@ -3481,12 +3497,6 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
34813497
_menu_option(VIEW_FRAME_TIME);
34823498
}
34833499
}
3484-
if (p_state.has("half_res")) {
3485-
bool half_res = p_state["half_res"];
3486-
3487-
int idx = view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION);
3488-
view_menu->get_popup()->set_item_checked(idx, half_res);
3489-
}
34903500
if (p_state.has("cinematic_preview")) {
34913501
previewing_cinema = p_state["cinematic_preview"];
34923502

@@ -3537,7 +3547,6 @@ Dictionary Node3DEditorViewport::get_state() const {
35373547
d["gizmos"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS));
35383548
d["information"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
35393549
d["frame_time"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME));
3540-
d["half_res"] = subviewport_container->get_stretch_shrink() > 1;
35413550
d["cinematic_preview"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW));
35423551
if (previewing) {
35433552
d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
@@ -4066,8 +4075,6 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
40664075
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_fps", TTR("View Frame Time")), VIEW_FRAME_TIME);
40674076
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true);
40684077
view_menu->get_popup()->add_separator();
4069-
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_half_resolution", TTR("Half Resolution")), VIEW_HALF_RESOLUTION);
4070-
view_menu->get_popup()->add_separator();
40714078
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER);
40724079
view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_doppler", TTR("Enable Doppler")), VIEW_AUDIO_DOPPLER);
40734080
view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS), true);

editor/plugins/node_3d_editor_plugin.h

-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ class Node3DEditorViewport : public Control {
191191
VIEW_PERSPECTIVE,
192192
VIEW_ENVIRONMENT,
193193
VIEW_ORTHOGONAL,
194-
VIEW_HALF_RESOLUTION,
195194
VIEW_AUDIO_LISTENER,
196195
VIEW_AUDIO_DOPPLER,
197196
VIEW_GIZMOS,

0 commit comments

Comments
 (0)