diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2021-10-29 18:32:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 18:32:38 +0300 |
commit | 23603e4892ce927ba192ce4ab9445de084556e8c (patch) | |
tree | b93938b3b345e85efcecda103b6a6535d18a6672 /editor | |
parent | 7d99ccda1d0ebe6b64a90995b062c28c1a517fe9 (diff) | |
parent | 2d0aa5ebc4fada2a27895b6853a9121a34786220 (diff) |
Merge pull request #54382 from Chaosus/vs_fog
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 33 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.h | 8 |
2 files changed, 40 insertions, 1 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index d0f3da8d81..6d023b8a7d 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1426,13 +1426,23 @@ void VisualShaderEditor::_set_mode(int p_which) { edit_type_standard->set_visible(false); edit_type_particles->set_visible(false); edit_type_sky->set_visible(true); + edit_type_fog->set_visible(false); edit_type = edit_type_sky; custom_mode_box->set_visible(false); mode = MODE_FLAGS_SKY; + } else if (p_which == VisualShader::MODE_FOG) { + edit_type_standard->set_visible(false); + edit_type_particles->set_visible(false); + edit_type_sky->set_visible(false); + edit_type_fog->set_visible(true); + edit_type = edit_type_fog; + custom_mode_box->set_visible(false); + mode = MODE_FLAGS_FOG; } else if (p_which == VisualShader::MODE_PARTICLES) { edit_type_standard->set_visible(false); edit_type_particles->set_visible(true); edit_type_sky->set_visible(false); + edit_type_fog->set_visible(false); edit_type = edit_type_particles; if ((edit_type->get_selected() + 3) > VisualShader::TYPE_PROCESS) { custom_mode_box->set_visible(false); @@ -1444,6 +1454,7 @@ void VisualShaderEditor::_set_mode(int p_which) { edit_type_particles->set_visible(false); edit_type_standard->set_visible(true); edit_type_sky->set_visible(false); + edit_type_fog->set_visible(false); edit_type = edit_type_standard; custom_mode_box->set_visible(false); mode = MODE_FLAGS_SPATIAL_CANVASITEM; @@ -1601,6 +1612,8 @@ VisualShader::Type VisualShaderEditor::get_current_shader_type() const { type = VisualShader::Type(edit_type->get_selected() + 3 + (custom_mode_enabled ? 3 : 0)); } else if (mode & MODE_FLAGS_SKY) { type = VisualShader::Type(edit_type->get_selected() + 8); + } else if (mode & MODE_FLAGS_FOG) { + type = VisualShader::Type(edit_type->get_selected() + 9); } else { type = VisualShader::Type(edit_type->get_selected()); } @@ -3520,6 +3533,8 @@ void VisualShaderEditor::_mode_selected(int p_id) { } } else if (mode & MODE_FLAGS_SKY) { offset = 8; + } else if (mode & MODE_FLAGS_FOG) { + offset = 9; } visual_shader->set_shader_type(VisualShader::Type(p_id + offset)); @@ -4062,6 +4077,11 @@ VisualShaderEditor::VisualShaderEditor() { edit_type_sky->select(0); edit_type_sky->connect("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected)); + edit_type_fog = memnew(OptionButton); + edit_type_fog->add_item(TTR("Fog")); + edit_type_fog->select(0); + edit_type_fog->connect("item_selected", callable_mp(this, &VisualShaderEditor::_mode_selected)); + edit_type = edit_type_standard; graph->get_zoom_hbox()->add_child(custom_mode_box); @@ -4072,6 +4092,8 @@ VisualShaderEditor::VisualShaderEditor() { graph->get_zoom_hbox()->move_child(edit_type_particles, 0); graph->get_zoom_hbox()->add_child(edit_type_sky); graph->get_zoom_hbox()->move_child(edit_type_sky, 0); + graph->get_zoom_hbox()->add_child(edit_type_fog); + graph->get_zoom_hbox()->move_child(edit_type_fog, 0); add_node = memnew(Button); add_node->set_flat(true); @@ -4340,6 +4362,7 @@ VisualShaderEditor::VisualShaderEditor() { const String input_param_for_fragment_and_light_shader_modes = TTR("'%s' input parameter for fragment and light shader modes."); const String input_param_for_fragment_shader_mode = TTR("'%s' input parameter for fragment shader mode."); const String input_param_for_sky_shader_mode = TTR("'%s' input parameter for sky shader mode."); + const String input_param_for_fog_shader_mode = TTR("'%s' input parameter for fog shader mode."); const String input_param_for_light_shader_mode = TTR("'%s' input parameter for light shader mode."); const String input_param_for_vertex_shader_mode = TTR("'%s' input parameter for vertex shader mode."); const String input_param_for_start_shader_mode = TTR("'%s' input parameter for start shader mode."); @@ -4459,6 +4482,16 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("SkyCoords", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_SKY, Shader::MODE_SKY)); add_options.push_back(AddOption("Time", "Input", "Sky", "VisualShaderNodeInput", vformat(input_param_for_sky_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_SKY, Shader::MODE_SKY)); + // FOG INPUTS + + add_options.push_back(AddOption("WorldPosition", "Input", "Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "world_position"), "world_position", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FOG, Shader::MODE_FOG)); + add_options.push_back(AddOption("ObjectPosition", "Input", "Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "object_position"), "object_position", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FOG, Shader::MODE_FOG)); + add_options.push_back(AddOption("UVW", "Input", "Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "uvw"), "uvw", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FOG, Shader::MODE_FOG)); + add_options.push_back(AddOption("Extents", "Input", "Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "extents"), "extents", VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FOG, Shader::MODE_FOG)); + add_options.push_back(AddOption("Transform", "Input", "Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_FOG, Shader::MODE_FOG)); + add_options.push_back(AddOption("SDF", "Input", "Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "sdf"), "sdf", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FOG, Shader::MODE_FOG)); + add_options.push_back(AddOption("Time", "Input", "Fog", "VisualShaderNodeInput", vformat(input_param_for_fog_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FOG, Shader::MODE_FOG)); + // PARTICLES INPUTS add_options.push_back(AddOption("CollisionDepth", "Input", "Collide", "VisualShaderNodeInput", vformat(input_param_for_collide_shader_mode, "collision_depth"), "collision_depth", VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_COLLIDE, Shader::MODE_PARTICLES)); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 5788959a77..58bbcb7113 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -145,6 +145,7 @@ class VisualShaderEditor : public VBoxContainer { OptionButton *edit_type_standard; OptionButton *edit_type_particles; OptionButton *edit_type_sky; + OptionButton *edit_type_fog; CheckBox *custom_mode_box; bool custom_mode_enabled = false; @@ -180,7 +181,8 @@ class VisualShaderEditor : public VBoxContainer { enum ShaderModeFlags { MODE_FLAGS_SPATIAL_CANVASITEM = 1, MODE_FLAGS_SKY = 2, - MODE_FLAGS_PARTICLES = 4 + MODE_FLAGS_PARTICLES = 4, + MODE_FLAGS_FOG = 8, }; int mode = MODE_FLAGS_SPATIAL_CANVASITEM; @@ -203,6 +205,10 @@ class VisualShaderEditor : public VBoxContainer { TYPE_FLAGS_SKY = 1, }; + enum FogTypeFlags { + TYPE_FLAGS_FOG = 1, + }; + enum ToolsMenuOptions { EXPAND_ALL, COLLAPSE_ALL |