Improve quality of mesh and material resource previews in the editor

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).
This commit is contained in:
Hugo Locurcio 2024-09-25 23:48:42 +02:00
parent f7c567e2f5
commit e468624d25
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C

View File

@ -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);