Browse Source

Fix and restore text, material and mesh previewers.

Juan Linietsky 6 years ago
parent
commit
53bec9deeb

+ 2 - 0
drivers/gles3/rasterizer_storage_gles3.cpp

@@ -5460,6 +5460,8 @@ RID RasterizerStorageGLES3::reflection_probe_create() {
 	reflection_probe->intensity = 1.0;
 	reflection_probe->intensity = 1.0;
 	reflection_probe->interior_ambient = Color();
 	reflection_probe->interior_ambient = Color();
 	reflection_probe->interior_ambient_energy = 1.0;
 	reflection_probe->interior_ambient_energy = 1.0;
+	reflection_probe->interior_ambient_probe_contrib = 0.0;
+
 	reflection_probe->max_distance = 0;
 	reflection_probe->max_distance = 0;
 	reflection_probe->extents = Vector3(1, 1, 1);
 	reflection_probe->extents = Vector3(1, 1, 1);
 	reflection_probe->origin_offset = Vector3(0, 0, 0);
 	reflection_probe->origin_offset = Vector3(0, 0, 0);

+ 2 - 0
editor/editor_node.cpp

@@ -5904,6 +5904,8 @@ EditorNode::EditorNode() {
 	add_editor_plugin(memnew(SkeletonEditorPlugin(this)));
 	add_editor_plugin(memnew(SkeletonEditorPlugin(this)));
 	add_editor_plugin(memnew(SkeletonIKEditorPlugin(this)));
 	add_editor_plugin(memnew(SkeletonIKEditorPlugin(this)));
 	add_editor_plugin(memnew(PhysicalBonePlugin(this)));
 	add_editor_plugin(memnew(PhysicalBonePlugin(this)));
+	add_editor_plugin(memnew(MeshEditorPlugin(this)));
+	add_editor_plugin(memnew(MaterialEditorPlugin(this)));
 
 
 	for (int i = 0; i < EditorPlugins::get_plugin_count(); i++)
 	for (int i = 0; i < EditorPlugins::get_plugin_count(); i++)
 		add_editor_plugin(EditorPlugins::create(i, this));
 		add_editor_plugin(EditorPlugins::create(i, this));

+ 5 - 1
editor/editor_themes.cpp

@@ -641,9 +641,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
 	theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
 	theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons"));
 	theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
 	theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE);
 
 
-	Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1, 2, 0, 0, 0);
+	Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1, 2, 0, 2, 2);
 	sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
 	sub_inspector_bg->set_border_width(MARGIN_LEFT, 2);
 	sub_inspector_bg->set_border_color(MARGIN_LEFT, accent_color * Color(1, 1, 1, 0.3));
 	sub_inspector_bg->set_border_color(MARGIN_LEFT, accent_color * Color(1, 1, 1, 0.3));
+	sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2);
+	sub_inspector_bg->set_border_color(MARGIN_RIGHT, accent_color * Color(1, 1, 1, 0.3));
+	sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2);
+	sub_inspector_bg->set_border_color(MARGIN_BOTTOM, accent_color * Color(1, 1, 1, 0.3));
 	sub_inspector_bg->set_draw_center(true);
 	sub_inspector_bg->set_draw_center(true);
 
 
 	theme->set_stylebox("sub_inspector_bg", "Editor", sub_inspector_bg);
 	theme->set_stylebox("sub_inspector_bg", "Editor", sub_inspector_bg);

+ 204 - 0
editor/plugins/material_editor_plugin.cpp

@@ -32,6 +32,210 @@
 
 
 #include "scene/resources/particles_material.h"
 #include "scene/resources/particles_material.h"
 
 
+void MaterialEditor::_notification(int p_what) {
+
+	if (p_what == NOTIFICATION_PHYSICS_PROCESS) {
+	}
+
+	if (p_what == NOTIFICATION_READY) {
+
+		//get_scene()->connect("node_removed",this,"_node_removed");
+
+		if (first_enter) {
+			//it's in propertyeditor so.. could be moved around
+
+			light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1", "EditorIcons"));
+			light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off", "EditorIcons"));
+			light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2", "EditorIcons"));
+			light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off", "EditorIcons"));
+
+			sphere_switch->set_normal_texture(get_icon("MaterialPreviewSphereOff", "EditorIcons"));
+			sphere_switch->set_pressed_texture(get_icon("MaterialPreviewSphere", "EditorIcons"));
+			box_switch->set_normal_texture(get_icon("MaterialPreviewCubeOff", "EditorIcons"));
+			box_switch->set_pressed_texture(get_icon("MaterialPreviewCube", "EditorIcons"));
+
+			first_enter = false;
+		}
+	}
+
+	if (p_what == NOTIFICATION_DRAW) {
+
+		Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
+		Size2 size = get_size();
+
+		draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
+	}
+}
+
+void MaterialEditor::edit(Ref<Material> p_material, const Ref<Environment> &p_env) {
+
+	material = p_material;
+	camera->set_environment(p_env);
+	if (!material.is_null()) {
+		sphere_instance->set_material_override(material);
+		box_instance->set_material_override(material);
+	} else {
+
+		hide();
+	}
+}
+
+void MaterialEditor::_button_pressed(Node *p_button) {
+
+	if (p_button == light_1_switch) {
+		light1->set_visible(!light_1_switch->is_pressed());
+	}
+
+	if (p_button == light_2_switch) {
+		light2->set_visible(!light_2_switch->is_pressed());
+	}
+
+	if (p_button == box_switch) {
+		box_instance->show();
+		sphere_instance->hide();
+		box_switch->set_pressed(true);
+		sphere_switch->set_pressed(false);
+	}
+
+	if (p_button == sphere_switch) {
+		box_instance->hide();
+		sphere_instance->show();
+		box_switch->set_pressed(false);
+		sphere_switch->set_pressed(true);
+	}
+}
+
+void MaterialEditor::_bind_methods() {
+
+	ClassDB::bind_method(D_METHOD("_button_pressed"), &MaterialEditor::_button_pressed);
+}
+
+MaterialEditor::MaterialEditor() {
+
+	vc = memnew(ViewportContainer);
+	vc->set_stretch(true);
+	add_child(vc);
+	vc->set_anchors_and_margins_preset(PRESET_WIDE);
+	viewport = memnew(Viewport);
+	Ref<World> world;
+	world.instance();
+	viewport->set_world(world); //use own world
+	vc->add_child(viewport);
+	viewport->set_disable_input(true);
+	viewport->set_transparent_background(true);
+	viewport->set_msaa(Viewport::MSAA_4X);
+
+	camera = memnew(Camera);
+	camera->set_transform(Transform(Basis(), Vector3(0, 0, 3)));
+	camera->set_perspective(45, 0.1, 10);
+	camera->make_current();
+	viewport->add_child(camera);
+
+	light1 = memnew(DirectionalLight);
+	light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
+	viewport->add_child(light1);
+
+	light2 = memnew(DirectionalLight);
+	light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
+	light2->set_color(Color(0.7, 0.7, 0.7));
+	viewport->add_child(light2);
+
+	sphere_instance = memnew(MeshInstance);
+	viewport->add_child(sphere_instance);
+
+	box_instance = memnew(MeshInstance);
+	viewport->add_child(box_instance);
+
+	Transform box_xform;
+	box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0));
+	box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0));
+	box_xform.basis.scale(Vector3(0.8, 0.8, 0.8));
+	box_xform.origin.y = 0.2;
+	box_instance->set_transform(box_xform);
+
+	sphere_mesh.instance();
+	sphere_instance->set_mesh(sphere_mesh);
+	box_mesh.instance();
+	box_instance->set_mesh(box_mesh);
+	box_instance->hide();
+
+	set_custom_minimum_size(Size2(1, 150) * EDSCALE);
+
+	HBoxContainer *hb = memnew(HBoxContainer);
+	add_child(hb);
+	hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
+
+	VBoxContainer *vb_shape = memnew(VBoxContainer);
+	hb->add_child(vb_shape);
+
+	sphere_switch = memnew(TextureButton);
+	sphere_switch->set_toggle_mode(true);
+	sphere_switch->set_pressed(true);
+	vb_shape->add_child(sphere_switch);
+	sphere_switch->connect("pressed", this, "_button_pressed", varray(sphere_switch));
+
+	box_switch = memnew(TextureButton);
+	box_switch->set_toggle_mode(true);
+	box_switch->set_pressed(false);
+	vb_shape->add_child(box_switch);
+	box_switch->connect("pressed", this, "_button_pressed", varray(box_switch));
+
+	hb->add_spacer();
+
+	VBoxContainer *vb_light = memnew(VBoxContainer);
+	hb->add_child(vb_light);
+
+	light_1_switch = memnew(TextureButton);
+	light_1_switch->set_toggle_mode(true);
+	vb_light->add_child(light_1_switch);
+	light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));
+
+	light_2_switch = memnew(TextureButton);
+	light_2_switch->set_toggle_mode(true);
+	vb_light->add_child(light_2_switch);
+	light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));
+
+	first_enter = true;
+}
+
+///////////////////////
+
+bool EditorInspectorPluginMaterial::can_handle(Object *p_object) {
+
+	Material *material = Object::cast_to<Material>(p_object);
+	if (!material)
+		return false;
+
+	return material->get_shader_mode() == Shader::MODE_SPATIAL;
+}
+
+void EditorInspectorPluginMaterial::parse_begin(Object *p_object) {
+
+	Material *material = Object::cast_to<Material>(p_object);
+	if (!material) {
+		return;
+	}
+	Ref<Material> m(material);
+
+	MaterialEditor *editor = memnew(MaterialEditor);
+	editor->edit(m, env);
+	add_custom_control(editor);
+}
+
+EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() {
+	env.instance();
+	Ref<ProceduralSky> proc_sky = memnew(ProceduralSky(true));
+	env->set_sky(proc_sky);
+	env->set_background(Environment::BG_COLOR_SKY);
+}
+
+MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) {
+
+	Ref<EditorInspectorPluginMaterial> plugin;
+	plugin.instance();
+	add_inspector_plugin(plugin);
+}
+
 String SpatialMaterialConversionPlugin::converts_to() const {
 String SpatialMaterialConversionPlugin::converts_to() const {
 
 
 	return "ShaderMaterial";
 	return "ShaderMaterial";

+ 65 - 0
editor/plugins/material_editor_plugin.h

@@ -32,6 +32,71 @@
 #define MATERIAL_EDITOR_PLUGIN_H
 #define MATERIAL_EDITOR_PLUGIN_H
 
 
 #include "editor/property_editor.h"
 #include "editor/property_editor.h"
+#include "scene/resources/primitive_meshes.h"
+
+#include "editor/editor_node.h"
+#include "editor/editor_plugin.h"
+#include "scene/3d/camera.h"
+#include "scene/3d/light.h"
+#include "scene/3d/mesh_instance.h"
+#include "scene/resources/material.h"
+
+class MaterialEditor : public Control {
+
+	GDCLASS(MaterialEditor, Control);
+
+	ViewportContainer *vc;
+	Viewport *viewport;
+	MeshInstance *sphere_instance;
+	MeshInstance *box_instance;
+	DirectionalLight *light1;
+	DirectionalLight *light2;
+	Camera *camera;
+
+	Ref<SphereMesh> sphere_mesh;
+	Ref<CubeMesh> box_mesh;
+
+	TextureButton *sphere_switch;
+	TextureButton *box_switch;
+
+	TextureButton *light_1_switch;
+	TextureButton *light_2_switch;
+
+	Ref<Material> material;
+
+	void _button_pressed(Node *p_button);
+	bool first_enter;
+
+protected:
+	void _notification(int p_what);
+
+	static void _bind_methods();
+
+public:
+	void edit(Ref<Material> p_material, const Ref<Environment> &p_env);
+	MaterialEditor();
+};
+
+class EditorInspectorPluginMaterial : public EditorInspectorPlugin {
+	GDCLASS(EditorInspectorPluginMaterial, EditorInspectorPlugin)
+	Ref<Environment> env;
+
+public:
+	virtual bool can_handle(Object *p_object);
+	virtual void parse_begin(Object *p_object);
+
+	EditorInspectorPluginMaterial();
+};
+
+class MaterialEditorPlugin : public EditorPlugin {
+
+	GDCLASS(MaterialEditorPlugin, EditorPlugin);
+
+public:
+	virtual String get_name() const { return "Material"; }
+
+	MaterialEditorPlugin(EditorNode *p_node);
+};
 
 
 class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin {
 class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin {
 	GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin)
 	GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin)

+ 31 - 46
editor/plugins/mesh_editor_plugin.cpp

@@ -80,26 +80,21 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) {
 	mesh = p_mesh;
 	mesh = p_mesh;
 	mesh_instance->set_mesh(mesh);
 	mesh_instance->set_mesh(mesh);
 
 
-	if (mesh.is_null()) {
-
-		hide();
-	} else {
-		rot_x = 0;
-		rot_y = 0;
-		_update_rotation();
-
-		AABB aabb = mesh->get_aabb();
-		Vector3 ofs = aabb.position + aabb.size * 0.5;
-		float m = aabb.get_longest_axis_size();
-		if (m != 0) {
-			m = 1.0 / m;
-			m *= 0.5;
-			Transform xform;
-			xform.basis.scale(Vector3(m, m, m));
-			xform.origin = -xform.basis.xform(ofs); //-ofs*m;
-			//xform.origin.z -= aabb.get_longest_axis_size() * 2;
-			mesh_instance->set_transform(xform);
-		}
+	rot_x = Math::deg2rad(-15.0);
+	rot_y = Math::deg2rad(30.0);
+	_update_rotation();
+
+	AABB aabb = mesh->get_aabb();
+	Vector3 ofs = aabb.position + aabb.size * 0.5;
+	float m = aabb.get_longest_axis_size();
+	if (m != 0) {
+		m = 1.0 / m;
+		m *= 0.5;
+		Transform xform;
+		xform.basis.scale(Vector3(m, m, m));
+		xform.origin = -xform.basis.xform(ofs); //-ofs*m;
+		//xform.origin.z -= aabb.get_longest_axis_size() * 2;
+		mesh_instance->set_transform(xform);
 	}
 	}
 }
 }
 
 
@@ -128,8 +123,8 @@ MeshEditor::MeshEditor() {
 	viewport->set_world(world); //use own world
 	viewport->set_world(world); //use own world
 	add_child(viewport);
 	add_child(viewport);
 	viewport->set_disable_input(true);
 	viewport->set_disable_input(true);
+	viewport->set_msaa(Viewport::MSAA_2X);
 	set_stretch(true);
 	set_stretch(true);
-
 	camera = memnew(Camera);
 	camera = memnew(Camera);
 	camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
 	camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
 	camera->set_perspective(45, 0.1, 10);
 	camera->set_perspective(45, 0.1, 10);
@@ -176,39 +171,29 @@ MeshEditor::MeshEditor() {
 	rot_y = 0;
 	rot_y = 0;
 }
 }
 
 
-void MeshEditorPlugin::edit(Object *p_object) {
-
-	Mesh *s = Object::cast_to<Mesh>(p_object);
-	if (!s)
-		return;
-
-	mesh_editor->edit(Ref<Mesh>(s));
-}
+///////////////////////
 
 
-bool MeshEditorPlugin::handles(Object *p_object) const {
+bool EditorInspectorPluginMesh::can_handle(Object *p_object) {
 
 
-	return p_object->is_class("Mesh");
+	return Object::cast_to<Mesh>(p_object) != NULL;
 }
 }
 
 
-void MeshEditorPlugin::make_visible(bool p_visible) {
+void EditorInspectorPluginMesh::parse_begin(Object *p_object) {
 
 
-	if (p_visible) {
-		mesh_editor->show();
-		//mesh_editor->set_process(true);
-	} else {
-
-		mesh_editor->hide();
-		//mesh_editor->set_process(false);
+	Mesh *mesh = Object::cast_to<Mesh>(p_object);
+	if (!mesh) {
+		return;
 	}
 	}
+	Ref<Mesh> m(mesh);
+
+	MeshEditor *editor = memnew(MeshEditor);
+	editor->edit(m);
+	add_custom_control(editor);
 }
 }
 
 
 MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) {
 MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) {
 
 
-	editor = p_node;
-	mesh_editor = memnew(MeshEditor);
-	add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, mesh_editor);
-	mesh_editor->hide();
-}
-
-MeshEditorPlugin::~MeshEditorPlugin() {
+	Ref<EditorInspectorPluginMesh> plugin;
+	plugin.instance();
+	add_inspector_plugin(plugin);
 }
 }

+ 7 - 8
editor/plugins/mesh_editor_plugin.h

@@ -72,22 +72,21 @@ public:
 	MeshEditor();
 	MeshEditor();
 };
 };
 
 
+class EditorInspectorPluginMesh : public EditorInspectorPlugin {
+	GDCLASS(EditorInspectorPluginMesh, EditorInspectorPlugin)
+public:
+	virtual bool can_handle(Object *p_object);
+	virtual void parse_begin(Object *p_object);
+};
+
 class MeshEditorPlugin : public EditorPlugin {
 class MeshEditorPlugin : public EditorPlugin {
 
 
 	GDCLASS(MeshEditorPlugin, EditorPlugin);
 	GDCLASS(MeshEditorPlugin, EditorPlugin);
 
 
-	MeshEditor *mesh_editor;
-	EditorNode *editor;
-
 public:
 public:
 	virtual String get_name() const { return "Mesh"; }
 	virtual String get_name() const { return "Mesh"; }
-	bool has_main_screen() const { return false; }
-	virtual void edit(Object *p_object);
-	virtual bool handles(Object *p_object) const;
-	virtual void make_visible(bool p_visible);
 
 
 	MeshEditorPlugin(EditorNode *p_node);
 	MeshEditorPlugin(EditorNode *p_node);
-	~MeshEditorPlugin();
 };
 };
 
 
 #endif
 #endif

+ 15 - 26
editor/plugins/texture_editor_plugin.cpp

@@ -138,39 +138,28 @@ TextureEditor::TextureEditor() {
 	set_custom_minimum_size(Size2(1, 150));
 	set_custom_minimum_size(Size2(1, 150));
 }
 }
 
 
-void TextureEditorPlugin::edit(Object *p_object) {
+//
+bool EditorInspectorPluginTexture::can_handle(Object *p_object) {
 
 
-	Texture *s = Object::cast_to<Texture>(p_object);
-	if (!s)
-		return;
-
-	texture_editor->edit(Ref<Texture>(s));
-}
-
-bool TextureEditorPlugin::handles(Object *p_object) const {
-
-	return p_object->is_class("Texture");
+	return Object::cast_to<Texture>(p_object) != NULL;
 }
 }
 
 
-void TextureEditorPlugin::make_visible(bool p_visible) {
+void EditorInspectorPluginTexture::parse_begin(Object *p_object) {
 
 
-	if (p_visible) {
-		texture_editor->show();
-		//texture_editor->set_process(true);
-	} else {
-
-		texture_editor->hide();
-		//texture_editor->set_process(false);
+	Texture *texture = Object::cast_to<Texture>(p_object);
+	if (!texture) {
+		return;
 	}
 	}
+	Ref<Texture> m(texture);
+
+	TextureEditor *editor = memnew(TextureEditor);
+	editor->edit(m);
+	add_custom_control(editor);
 }
 }
 
 
 TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) {
 TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) {
 
 
-	editor = p_node;
-	texture_editor = memnew(TextureEditor);
-	add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, texture_editor);
-	texture_editor->hide();
-}
-
-TextureEditorPlugin::~TextureEditorPlugin() {
+	Ref<EditorInspectorPluginTexture> plugin;
+	plugin.instance();
+	add_inspector_plugin(plugin);
 }
 }

+ 7 - 8
editor/plugins/texture_editor_plugin.h

@@ -52,22 +52,21 @@ public:
 	TextureEditor();
 	TextureEditor();
 };
 };
 
 
+class EditorInspectorPluginTexture : public EditorInspectorPlugin {
+	GDCLASS(EditorInspectorPluginTexture, EditorInspectorPlugin)
+public:
+	virtual bool can_handle(Object *p_object);
+	virtual void parse_begin(Object *p_object);
+};
+
 class TextureEditorPlugin : public EditorPlugin {
 class TextureEditorPlugin : public EditorPlugin {
 
 
 	GDCLASS(TextureEditorPlugin, EditorPlugin);
 	GDCLASS(TextureEditorPlugin, EditorPlugin);
 
 
-	TextureEditor *texture_editor;
-	EditorNode *editor;
-
 public:
 public:
 	virtual String get_name() const { return "Texture"; }
 	virtual String get_name() const { return "Texture"; }
-	bool has_main_screen() const { return false; }
-	virtual void edit(Object *p_object);
-	virtual bool handles(Object *p_object) const;
-	virtual void make_visible(bool p_visible);
 
 
 	TextureEditorPlugin(EditorNode *p_node);
 	TextureEditorPlugin(EditorNode *p_node);
-	~TextureEditorPlugin();
 };
 };
 
 
 #endif // TEXTURE_EDITOR_PLUGIN_H
 #endif // TEXTURE_EDITOR_PLUGIN_H

+ 7 - 1
scene/resources/sky.cpp

@@ -536,7 +536,7 @@ void ProceduralSky::_bind_methods() {
 	BIND_ENUM_CONSTANT(TEXTURE_SIZE_MAX);
 	BIND_ENUM_CONSTANT(TEXTURE_SIZE_MAX);
 }
 }
 
 
-ProceduralSky::ProceduralSky() {
+ProceduralSky::ProceduralSky(bool p_desaturate) {
 
 
 	sky = VS::get_singleton()->sky_create();
 	sky = VS::get_singleton()->sky_create();
 	texture = VS::get_singleton()->texture_create();
 	texture = VS::get_singleton()->texture_create();
@@ -552,6 +552,12 @@ ProceduralSky::ProceduralSky() {
 	ground_curve = 0.02;
 	ground_curve = 0.02;
 	ground_energy = 1;
 	ground_energy = 1;
 
 
+	if (p_desaturate) {
+		sky_top_color.set_hsv(sky_top_color.get_h(),0,sky_top_color.get_v());
+		sky_horizon_color.set_hsv(sky_horizon_color.get_h(),0,sky_horizon_color.get_v());
+		ground_bottom_color.set_hsv(ground_bottom_color.get_h(),0,ground_bottom_color.get_v());
+		ground_horizon_color.set_hsv(ground_horizon_color.get_h(),0,ground_horizon_color.get_v());
+	}
 	sun_color = Color(1, 1, 1);
 	sun_color = Color(1, 1, 1);
 	sun_latitude = 35;
 	sun_latitude = 35;
 	sun_longitude = 0;
 	sun_longitude = 0;

+ 1 - 1
scene/resources/sky.h

@@ -191,7 +191,7 @@ public:
 
 
 	virtual RID get_rid() const;
 	virtual RID get_rid() const;
 
 
-	ProceduralSky();
+	ProceduralSky(bool p_desaturate=false);
 	~ProceduralSky();
 	~ProceduralSky();
 };
 };