From e468624d250c502b34e47b5ae86aa677242ad09b Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 25 Sep 2024 23:48:42 +0200 Subject: [PATCH] Improve quality of mesh and material resource previews in the editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses a combination of MSAA and SSAA to make thumbnails smoother while also improving texture sampling quality. Thumbnail generation time is largely unaffected since most of the time is spent doing things on the CPU anyway, and the thumbnail resolution is still 128×128 (although the 3D buffer is internally 256×256 now). --- editor/plugins/editor_preview_plugins.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index a2c36b1f3ce..c4c86d3103f 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -362,6 +362,9 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); RS::get_singleton()->viewport_set_scenario(viewport, scenario); RS::get_singleton()->viewport_set_size(viewport, 128, 128); + // Use 4× MSAA and 4× SSAA to avoid aliasing on edges and improve texture quality, which helps with thumbnail recognition. + RS::get_singleton()->viewport_set_msaa_3d(viewport, RenderingServer::VIEWPORT_MSAA_4X); + RS::get_singleton()->viewport_set_scaling_3d_scale(viewport, 2.0); RS::get_singleton()->viewport_set_transparent_background(viewport, true); RS::get_singleton()->viewport_set_active(viewport, true); viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); @@ -786,6 +789,9 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); RS::get_singleton()->viewport_set_scenario(viewport, scenario); RS::get_singleton()->viewport_set_size(viewport, 128, 128); + // Use 4× MSAA and 4× SSAA to avoid aliasing on edges and improve texture quality, which helps with thumbnail recognition. + RS::get_singleton()->viewport_set_msaa_3d(viewport, RenderingServer::VIEWPORT_MSAA_4X); + RS::get_singleton()->viewport_set_scaling_3d_scale(viewport, 2.0); RS::get_singleton()->viewport_set_transparent_background(viewport, true); RS::get_singleton()->viewport_set_active(viewport, true); viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);