diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2021-07-21 12:57:11 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2021-07-21 13:02:23 +0300 |
commit | 40419a394dc500a0dd4028eae8f5f92876cff9e6 (patch) | |
tree | 157366e28109577d8ebc7b37ed16d2ea1ba19ce1 /scene | |
parent | 8cc599db645a356ca6af3bc15e7574fa6e3ada0e (diff) |
Fix function code generation for uniform triplanar node in visual shader
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/visual_shader.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 0f6412e6e9..ef380ab233 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -1740,6 +1740,7 @@ void VisualShader::_update_shader() const { } Map<int, String> code_map; + Set<int> empty_funcs; for (int i = 0; i < TYPE_MAX; i++) { if (!has_func_name(RenderingServer::ShaderMode(shader_mode), func_name[i])) { @@ -1776,6 +1777,7 @@ void VisualShader::_update_shader() const { } if (is_empty_func) { + empty_funcs.insert(i); continue; } @@ -1934,7 +1936,11 @@ void VisualShader::_update_shader() const { if (!has_func_name(RenderingServer::ShaderMode(shader_mode), func_name[i])) { continue; } - tcode = tcode.insert(insertion_pos[i], global_code_per_func[Type(i)]); + String func_code = global_code_per_func[Type(i)].as_string(); + if (empty_funcs.has(Type(i)) && !func_code.is_empty()) { + func_code = vformat("%s%s%s", String("\nvoid " + String(func_name[i]) + "() {\n"), func_code, "}\n"); + } + tcode = tcode.insert(insertion_pos[i], func_code); } final_code += tcode; |