diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 12 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 3 | ||||
-rw-r--r-- | editor/icons/Sky.svg | 1 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.cpp | 119 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.h | 27 | ||||
-rw-r--r-- | editor/project_manager.cpp | 2 |
6 files changed, 159 insertions, 5 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 61480c3c20..f40762586e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6584,6 +6584,18 @@ EditorNode::EditorNode() { particles_mat_convert.instance(); resource_conversion_plugins.push_back(particles_mat_convert); + Ref<ProceduralSkyMaterialConversionPlugin> procedural_sky_mat_convert; + procedural_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(procedural_sky_mat_convert); + + Ref<PanoramaSkyMaterialConversionPlugin> panorama_sky_mat_convert; + panorama_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(panorama_sky_mat_convert); + + Ref<PhysicalSkyMaterialConversionPlugin> physical_sky_mat_convert; + physical_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(physical_sky_mat_convert); + Ref<VisualShaderConversionPlugin> vshader_convert; vshader_convert.instance(); resource_conversion_plugins.push_back(vshader_convert); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 39d4b70a6a..1263eb166b 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -187,8 +187,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = exceptions.insert("EditorHandle"); exceptions.insert("Editor3DHandle"); exceptions.insert("Godot"); - exceptions.insert("PanoramaSky"); - exceptions.insert("ProceduralSky"); + exceptions.insert("Sky"); exceptions.insert("EditorControlAnchor"); exceptions.insert("DefaultProjectIcon"); exceptions.insert("GuiCloseCustomizable"); diff --git a/editor/icons/Sky.svg b/editor/icons/Sky.svg new file mode 100644 index 0000000000..356a966fe9 --- /dev/null +++ b/editor/icons/Sky.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="8" x2="8" y1="1040.4" y2="1050.4"><stop offset="0" stop-color="#1ec3ff"/><stop offset="1" stop-color="#b2e1ff"/></linearGradient><g transform="translate(0 -1037.4)"><path d="m8 1040.4a7 7 0 0 0 -7 7 7 7 0 0 0 .68555 3h12.631a7 7 0 0 0 .68359-3 7 7 0 0 0 -7-7z" fill="url(#a)"/><path d="m10 7c-.554 0-1 .446-1 1h-1c-.554 0-1 .446-1 1s.446 1 1 1h2c.554 0 1-.446 1-1h1c.554 0 1-.446 1-1s-.446-1-1-1zm-7 3c-.554 0-1 .446-1 1s.446 1 1 1h1c.554 0 1-.446 1-1s-.446-1-1-1z" fill="#fff" transform="translate(0 1037.4)"/></g></svg>
\ No newline at end of file diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index b39465f618..d388296927 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -33,6 +33,7 @@ #include "editor/editor_scale.h" #include "scene/gui/viewport_container.h" #include "scene/resources/particles_material.h" +#include "scene/resources/sky_material.h" void MaterialEditor::_notification(int p_what) { @@ -221,8 +222,8 @@ void EditorInspectorPluginMaterial::parse_begin(Object *p_object) { EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() { env.instance(); - Ref<ProceduralSky> proc_sky = memnew(ProceduralSky(true)); - env->set_sky(proc_sky); + Ref<Sky> sky = memnew(Sky()); + env->set_sky(sky); env->set_background(Environment::BG_COLOR); env->set_ambient_source(Environment::AMBIENT_SOURCE_SKY); env->set_reflection_source(Environment::REFLECTION_SOURCE_SKY); @@ -356,3 +357,117 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p smat->set_render_priority(mat->get_render_priority()); return smat; } + +String ProceduralSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool ProceduralSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<ProceduralSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<ProceduralSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} + +String PanoramaSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool PanoramaSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<PanoramaSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<PanoramaSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} + +String PhysicalSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool PhysicalSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<PhysicalSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<PhysicalSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 95a6c4bf8f..84e69425d0 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -127,4 +127,31 @@ public: virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; +class ProceduralSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(ProceduralSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + +class PanoramaSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(PanoramaSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + +class PhysicalSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(PhysicalSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + #endif // MATERIAL_EDITOR_PLUGIN_H diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 94f9bf2767..4e157e927e 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -505,7 +505,7 @@ private: set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=2]"); - f->store_line("[sub_resource type=\"ProceduralSky\" id=1]"); + f->store_line("[sub_resource type=\"Sky\" id=1]"); f->store_line("[resource]"); f->store_line("background_mode = 2"); f->store_line("background_sky = SubResource( 1 )"); |