Skip to content

Commit f620969

Browse files
committed
Improve the appearance of material thumbnails
1 parent 3b16d96 commit f620969

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

editor/inspector/editor_preview_plugins.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "editor/file_system/editor_paths.h"
3838
#include "editor/settings/editor_settings.h"
3939
#include "editor/themes/editor_scale.h"
40+
#include "scene/resources/3d/sky_material.h"
4041
#include "scene/resources/atlas_texture.h"
4142
#include "scene/resources/bit_map.h"
4243
#include "scene/resources/font.h"
@@ -362,6 +363,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
362363
RS::get_singleton()->viewport_set_scenario(viewport, scenario);
363364
RS::get_singleton()->viewport_set_size(viewport, 128, 128);
364365
RS::get_singleton()->viewport_set_transparent_background(viewport, true);
366+
RS::get_singleton()->viewport_set_msaa_3d(viewport, RS::VIEWPORT_MSAA_4X);
365367
RS::get_singleton()->viewport_set_active(viewport, true);
366368
viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
367369

@@ -370,6 +372,15 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
370372
RS::get_singleton()->camera_set_transform(camera, Transform3D(Basis(), Vector3(0, 0, 3)));
371373
RS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10);
372374

375+
sky = RS::get_singleton()->sky_create();
376+
sky_material.instantiate();
377+
RS::get_singleton()->sky_set_material(sky, sky_material->get_rid());
378+
379+
environment = RS::get_singleton()->environment_create();
380+
RS::get_singleton()->environment_set_background(environment, RS::ENV_BG_SKY);
381+
RS::get_singleton()->environment_set_sky(environment, sky);
382+
RS::get_singleton()->camera_set_environment(camera, environment);
383+
373384
if (GLOBAL_GET("rendering/lights_and_shadows/use_physical_light_units")) {
374385
camera_attributes = RS::get_singleton()->camera_attributes_create();
375386
RS::get_singleton()->camera_attributes_set_exposure(camera_attributes, 1.0, 0.000032552); // Matches default CameraAttributesPhysical to work well with default DirectionalLight3Ds.
@@ -391,7 +402,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
391402
sphere = RS::get_singleton()->mesh_create();
392403
sphere_instance = RS::get_singleton()->instance_create2(sphere, scenario);
393404

394-
int lats = 32;
405+
int lats = 16;
395406
int lons = 32;
396407
const double lat_step = Math::PI / lats;
397408
const double lon_step = Math::TAU / lons;

editor/inspector/editor_preview_plugins.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "editor/inspector/editor_resource_preview.h"
3535

3636
class ScriptLanguage;
37+
class ProceduralSkyMaterial;
3738

3839
void post_process_preview(Ref<Image> p_image);
3940

@@ -87,6 +88,9 @@ class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
8788
RID light_instance2;
8889
RID camera;
8990
RID camera_attributes;
91+
RID environment;
92+
RID sky;
93+
Ref<ProceduralSkyMaterial> sky_material;
9094
mutable DrawRequester draw_requester;
9195

9296
public:

0 commit comments

Comments
 (0)