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,10 +372,20 @@ 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.
376387		RS::get_singleton ()->camera_set_camera_attributes (camera, camera_attributes);
388+ 		RS::get_singleton ()->environment_set_bg_energy (environment, 1 .0f , 30000 .0f );
377389	}
378390
379391	light = RS::get_singleton ()->directional_light_create ();
@@ -391,7 +403,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
391403	sphere = RS::get_singleton ()->mesh_create ();
392404	sphere_instance = RS::get_singleton ()->instance_create2 (sphere, scenario);
393405
394- 	int  lats = 32 ;
406+ 	int  lats = 16 ;
395407	int  lons = 32 ;
396408	const  double  lat_step = Math::PI / lats;
397409	const  double  lon_step = Math::TAU / lons;
@@ -482,6 +494,8 @@ EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() {
482494	RS::get_singleton ()->free_rid (camera);
483495	RS::get_singleton ()->free_rid (camera_attributes);
484496	RS::get_singleton ()->free_rid (scenario);
497+ 	RS::get_singleton ()->free_rid (sky);
498+ 	RS::get_singleton ()->free_rid (environment);
485499}
486500
487501// /////////////////////////////////////////////////////////////////////////
0 commit comments