diff options
author | bitsawer <sawerduster@gmail.com> | 2023-01-22 22:19:52 +0200 |
---|---|---|
committer | bitsawer <sawerduster@gmail.com> | 2023-01-22 22:19:52 +0200 |
commit | 81f9529a7ea0ddbd815040fcd69fc33532d2afd3 (patch) | |
tree | 2359b21a58656479175302387d989b226c9536e7 /scene/resources | |
parent | eaf306e0b15e4283883f06bf903b05711a4dbfe8 (diff) |
Fix shader include dependency handling
Diffstat (limited to 'scene/resources')
-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); |