Skip to content

Commit d5fd611

Browse files
committed
Merge pull request #75787 from Calinou/advanced-import-settings-tweak-environment
Tweak environment in the Advanced Import Settings dialog
2 parents 029aade + 7259985 commit d5fd611

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

editor/import/3d/scene_import_settings.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,28 @@ SceneImportSettingsDialog::SceneImportSettingsDialog() {
16531653
camera->set_attributes(camera_attributes);
16541654
}
16551655

1656+
// Use a grayscale gradient sky to avoid skewing the preview towards a specific color,
1657+
// but still allow shaded areas to be easily distinguished (using the ambient and reflected light).
1658+
// This also helps the user orient themselves in the preview, since the bottom of the sky is black
1659+
// and the top of the sky is white.
1660+
procedural_sky_material.instantiate();
1661+
procedural_sky_material->set_sky_top_color(Color(1, 1, 1));
1662+
procedural_sky_material->set_sky_horizon_color(Color(0.5, 0.5, 0.5));
1663+
procedural_sky_material->set_ground_horizon_color(Color(0.5, 0.5, 0.5));
1664+
procedural_sky_material->set_ground_bottom_color(Color(0, 0, 0));
1665+
procedural_sky_material->set_sky_curve(2.0);
1666+
procedural_sky_material->set_ground_curve(0.5);
1667+
// Hide the sun from the sky.
1668+
procedural_sky_material->set_sun_angle_max(0.0);
1669+
sky.instantiate();
1670+
sky->set_material(procedural_sky_material);
1671+
environment.instantiate();
1672+
environment->set_background(Environment::BG_SKY);
1673+
environment->set_sky(sky);
1674+
// A custom FOV must be specified, as an orthogonal camera is used for the preview.
1675+
environment->set_sky_custom_fov(50.0);
1676+
camera->set_environment(environment);
1677+
16561678
light = memnew(DirectionalLight3D);
16571679
light->set_transform(Transform3D().looking_at(Vector3(-1, -2, -0.6), Vector3(0, 1, 0)));
16581680
base_viewport->add_child(light);

editor/import/3d/scene_import_settings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "scene/gui/tab_container.h"
4848
#include "scene/gui/tree.h"
4949
#include "scene/resources/3d/primitive_meshes.h"
50+
#include "scene/resources/3d/sky_material.h"
5051

5152
class EditorFileDialog;
5253
class EditorInspector;
@@ -78,6 +79,9 @@ class SceneImportSettingsDialog : public ConfirmationDialog {
7879

7980
Camera3D *camera = nullptr;
8081
Ref<CameraAttributesPractical> camera_attributes;
82+
Ref<Environment> environment;
83+
Ref<Sky> sky;
84+
Ref<ProceduralSkyMaterial> procedural_sky_material;
8185
bool first_aabb = false;
8286
AABB contents_aabb;
8387

0 commit comments

Comments
 (0)