diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2023-01-12 01:01:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-12 01:01:24 +0100 |
commit | 0abd60b9530d574fc8fc466e6a3f0c5b9814f697 (patch) | |
tree | 885784d2983af11d928a25784e0df516e8276498 /servers/rendering/shader_compiler.cpp | |
parent | 2fcd298f96b75b77df368e67129c9d13a53adfbd (diff) | |
parent | 89766848de1667df071174a8b2d5b3e67b53a0e6 (diff) |
Merge pull request #71130 from clayjohn/RD-normal-roughness
Fix multiple issues that make the normal roughness texture unusable
Diffstat (limited to 'servers/rendering/shader_compiler.cpp')
-rw-r--r-- | servers/rendering/shader_compiler.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 57215d9d63..626da90168 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -1183,6 +1183,10 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene code += "("; + // if normal roughness texture is used, we will add logic to automatically switch between + // sampler2D and sampler2D array and vec2 UV and vec3 UV. + bool normal_roughness_texture_used = false; + for (int i = 1; i < onode->arguments.size(); i++) { if (i > 1) { code += ", "; @@ -1282,11 +1286,24 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } - code += ShaderLanguage::get_datatype_name(onode->arguments[i]->get_datatype()) + "(" + node_code + ", " + sampler_name + ")"; + String data_type_name = ""; + if (texture_uniform == "NORMAL_ROUGHNESS_TEXTURE") { + data_type_name = "multiviewSampler"; + normal_roughness_texture_used = true; + } else { + data_type_name = ShaderLanguage::get_datatype_name(onode->arguments[i]->get_datatype()); + } + + code += data_type_name + "(" + node_code + ", " + sampler_name + ")"; } else { code += node_code; } } else { + if (normal_roughness_texture_used && i == 2) { + // UV coordinate after using normal roughness texture. + node_code = "normal_roughness_uv(" + node_code + ".xy)"; + } + code += node_code; } } |