diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2021-10-07 10:00:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-07 10:00:12 +0300 |
commit | 410cab4c619e2e8f9db05eed594d61751fbd92e7 (patch) | |
tree | f838cb9691cdfeb0a8dd509bf7eebad87a33a505 /servers | |
parent | 6eb2094d4dce0d7489e86a993f8d96ff2cfd22d3 (diff) | |
parent | b5028da5c033e8eb122a5963e05be6b2416e564e (diff) |
Merge pull request #53491 from Chaosus/shader_fix_texture_array_uniforms
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/renderer_storage_rd.cpp | 3 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shader_compiler_rd.cpp | 22 |
2 files changed, 13 insertions, 12 deletions
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 771be4bb3d..45d3b3f09f 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -2715,8 +2715,7 @@ void RendererStorageRD::MaterialData::update_textures(const Map<StringName, Vari p_textures[k++] = rd_texture; } } else { - p_textures[k] = rd_texture; - ++k; + p_textures[k++] = rd_texture; } } else { bool srgb = p_use_linear_color && (p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO); diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp index 2f4671785a..4c26941dae 100644 --- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp @@ -1230,22 +1230,24 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge code += ", "; } String node_code = _dump_node_code(onode->arguments[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning); - if (is_texture_func && i == 1 && (onode->arguments[i]->type == SL::Node::TYPE_VARIABLE || onode->arguments[i]->type == SL::Node::TYPE_OPERATOR)) { + if (is_texture_func && i == 1) { //need to map from texture to sampler in order to sample StringName texture_uniform; bool correct_texture_uniform = false; - if (onode->arguments[i]->type == SL::Node::TYPE_VARIABLE) { - const SL::VariableNode *varnode = static_cast<const SL::VariableNode *>(onode->arguments[i]); - texture_uniform = varnode->name; - correct_texture_uniform = true; - } else { // array indexing operator handling - const SL::OperatorNode *opnode = static_cast<const SL::OperatorNode *>(onode->arguments[i]); - if (opnode->op == SL::Operator::OP_INDEX && opnode->arguments[0]->type == SL::Node::TYPE_ARRAY) { - const SL::ArrayNode *anode = static_cast<const SL::ArrayNode *>(opnode->arguments[0]); + switch (onode->arguments[i]->type) { + case SL::Node::TYPE_VARIABLE: { + const SL::VariableNode *varnode = static_cast<const SL::VariableNode *>(onode->arguments[i]); + texture_uniform = varnode->name; + correct_texture_uniform = true; + } break; + case SL::Node::TYPE_ARRAY: { + const SL::ArrayNode *anode = static_cast<const SL::ArrayNode *>(onode->arguments[i]); texture_uniform = anode->name; correct_texture_uniform = true; - } + } break; + default: + break; } if (correct_texture_uniform) { |