diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-24 09:47:28 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-24 09:47:28 +0100 |
commit | 06c930caf1938c72c03388e16de1024dfca8ba00 (patch) | |
tree | f748aef4437852a852f8697d95dcfe46d5596ca8 | |
parent | 885cb808db31a4e3d4e9e394cc94fccacc7082d3 (diff) | |
parent | 81f9529a7ea0ddbd815040fcd69fc33532d2afd3 (diff) |
Merge pull request #71878 from bitsawer/fix_shader_dependencies
Fix shader include dependency handling
-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); |