1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Merge pull request #30152 from Chaosus/vs_conversion

Added convertor from VisualShader to Shader
This commit is contained in:
Rémi Verschelde
2019-06-29 18:40:28 +02:00
committed by GitHub
3 changed files with 40 additions and 0 deletions

View File

@@ -6342,6 +6342,10 @@ EditorNode::EditorNode() {
Ref<ParticlesMaterialConversionPlugin> particles_mat_convert; Ref<ParticlesMaterialConversionPlugin> particles_mat_convert;
particles_mat_convert.instance(); particles_mat_convert.instance();
resource_conversion_plugins.push_back(particles_mat_convert); resource_conversion_plugins.push_back(particles_mat_convert);
Ref<VisualShaderConversionPlugin> vshader_convert;
vshader_convert.instance();
resource_conversion_plugins.push_back(vshader_convert);
} }
update_spinner_step_msec = OS::get_singleton()->get_ticks_msec(); update_spinner_step_msec = OS::get_singleton()->get_ticks_msec();
update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn(); update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn();

View File

@@ -2771,3 +2771,30 @@ void VisualShaderNodePortPreview::_bind_methods() {
VisualShaderNodePortPreview::VisualShaderNodePortPreview() { VisualShaderNodePortPreview::VisualShaderNodePortPreview() {
} }
//////////////////////////////////
String VisualShaderConversionPlugin::converts_to() const {
return "Shader";
}
bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) const {
Ref<VisualShader> vshader = p_resource;
return vshader.is_valid();
}
Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<VisualShader> vshader = p_resource;
ERR_FAIL_COND_V(!vshader.is_valid(), Ref<Resource>());
Ref<Shader> shader;
shader.instance();
String code = vshader->get_code();
shader->set_code(code);
return shader;
}

View File

@@ -302,4 +302,13 @@ public:
VisualShaderNodePortPreview(); VisualShaderNodePortPreview();
}; };
class VisualShaderConversionPlugin : public EditorResourceConversionPlugin {
GDCLASS(VisualShaderConversionPlugin, 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 // VISUAL_SHADER_EDITOR_PLUGIN_H #endif // VISUAL_SHADER_EDITOR_PLUGIN_H