Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default color for preview environment #58

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@
<member name="rendering/driver/threads/thread_model" type="int" setter="" getter="" default="1" experimental="This setting has several known bugs which can lead to crashing, especially when using particles or resizing the window. Not recommended for use in production at this stage.">
The thread model to use for rendering. Rendering on a thread may improve performance, but synchronizing to the main thread can cause a bit more jitter.
</member>
<member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color(0.3, 0.3, 0.3, 1)">
<member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color(0.155, 0.151, 0.236, 1)">
Default background clear color. Overridable per [Viewport] using its [Environment]. See [member Environment.background_mode] and [member Environment.background_color] in particular. To change this default color programmatically, use [method RenderingServer.set_default_clear_color].
</member>
<member name="rendering/environment/defaults/default_environment" type="String" setter="" getter="" default="&quot;&quot;">
Expand Down
14 changes: 11 additions & 3 deletions editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6136,6 +6136,7 @@ Dictionary Node3DEditor::get_state() const {
pd["sun_rotation"] = sun_rotation;

pd["environ_sky_color"] = environ_sky_color->get_pick_color();
pd["environ_hz_color"] = environ_hz_color->get_pick_color();
pd["environ_ground_color"] = environ_ground_color->get_pick_color();
pd["environ_energy"] = environ_energy->get_value();
pd["environ_glow_enabled"] = environ_glow_button->is_pressed();
Expand Down Expand Up @@ -7887,6 +7888,7 @@ void Node3DEditor::_update_theme() {

sun_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor))));
environ_sky_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor))));
environ_hz_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor))));
environ_ground_color->set_custom_minimum_size(Size2(0, get_theme_constant(SNAME("color_picker_button_height"), EditorStringName(Editor))));

context_toolbar_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("ContextualToolbar"), EditorStringName(EditorStyles)));
Expand Down Expand Up @@ -8383,7 +8385,7 @@ void Node3DEditor::_preview_settings_changed() {

{ //preview env
sky_material->set_sky_energy_multiplier(environ_energy->get_value());
Color hz_color = environ_sky_color->get_pick_color().lerp(environ_ground_color->get_pick_color(), 0.5).lerp(Color(1, 1, 1), 0.5);
Color hz_color = environ_sky_color->get_pick_color().lerp(environ_ground_color->get_pick_color(), 0.5).lerp(environ_hz_color->get_pick_color(), 0.5);
sky_material->set_sky_top_color(environ_sky_color->get_pick_color());
sky_material->set_sky_horizon_color(hz_color);
sky_material->set_ground_bottom_color(environ_ground_color->get_pick_color());
Expand All @@ -8410,8 +8412,9 @@ void Node3DEditor::_load_default_preview_settings() {
sun_angle_altitude->set_value(-Math::rad_to_deg(sun_rotation.x));
sun_angle_azimuth->set_value(180.0 - Math::rad_to_deg(sun_rotation.y));
sun_direction->queue_redraw();
environ_sky_color->set_pick_color(Color(0.385, 0.454, 0.55));
environ_ground_color->set_pick_color(Color(0.2, 0.169, 0.133));
environ_sky_color->set_pick_color(Color(0.141, 0.289, 0.447));
environ_hz_color->set_pick_color(Color(0.447, 0.443, 0.612));
environ_ground_color->set_pick_color(Color(0.333, 0.333, 0.333));
environ_energy->set_value(1.0);
if (OS::get_singleton()->get_current_rendering_method() != "gl_compatibility") {
environ_glow_button->set_pressed(true);
Expand Down Expand Up @@ -9070,6 +9073,11 @@ void fragment() {
environ_sky_color->connect("color_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
environ_sky_color->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(environ_sky_color->get_picker()));
environ_vb->add_margin_child(TTR("Sky Color"), environ_sky_color);
environ_hz_color = memnew(ColorPickerButton);
environ_hz_color->set_edit_alpha(false);
environ_hz_color->connect("color_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
environ_hz_color->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(environ_hz_color->get_picker()));
environ_vb->add_margin_child(TTR("Horizon Color"), environ_hz_color);
environ_ground_color = memnew(ColorPickerButton);
environ_ground_color->connect("color_changed", callable_mp(this, &Node3DEditor::_preview_settings_changed).unbind(1));
environ_ground_color->set_edit_alpha(false);
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/node_3d_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ class Node3DEditor : public VBoxContainer {
Label *environ_title = nullptr;
VBoxContainer *environ_vb = nullptr;
ColorPickerButton *environ_sky_color = nullptr;
ColorPickerButton *environ_hz_color = nullptr;
ColorPickerButton *environ_ground_color = nullptr;
EditorSpinSlider *environ_energy = nullptr;
Button *environ_ao_button = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2944,7 +2944,7 @@ Error Main::setup2(bool p_show_boot_logo) {
DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP, true);
}

Color clear = GLOBAL_DEF_BASIC("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3));
Color clear = GLOBAL_DEF_BASIC("rendering/environment/defaults/default_clear_color", Color(0.155, 0.151, 0.236));
RenderingServer::get_singleton()->set_default_clear_color(clear);

if (p_show_boot_logo) {
Expand Down
Loading