diff options
-rw-r--r-- | scene/resources/shader.cpp | 7 | ||||
-rw-r--r-- | scene/resources/shader.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index b3952e745f..a09dbd50cf 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -42,9 +42,12 @@ Shader::Mode Shader::get_mode() const { } void Shader::_dependency_changed() { - RenderingServer::get_singleton()->shader_set_code(shader, RenderingServer::get_singleton()->shader_get_code(shader)); + // Preprocess and compile the code again because a dependency has changed. It also calls emit_changed() for us. + _recompile(); +} - emit_changed(); +void Shader::_recompile() { + set_code(get_code()); } void Shader::set_path(const String &p_path, bool p_take_over) { diff --git a/scene/resources/shader.h b/scene/resources/shader.h index 75c490e912..55608b6c11 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -60,6 +60,7 @@ private: HashMap<StringName, HashMap<int, Ref<Texture2D>>> default_textures; void _dependency_changed(); + void _recompile(); virtual void _update_shader() const; //used for visual shader Array _get_shader_uniform_list(bool p_get_groups = false); |