Merge pull request #94462 from jsjtxietian/more-type

Make ShaderLanguage's parser recognize sampler passed in from array
This commit is contained in:
Rémi Verschelde 2024-07-17 12:24:11 +02:00
commit a963f111cb
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -5548,10 +5548,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
}
}
if (is_sampler_type(call_function->arguments[i].type)) {
//let's see where our argument comes from
ERR_CONTINUE(n->type != Node::NODE_TYPE_VARIABLE); //bug? this should always be a variable
VariableNode *vn = static_cast<VariableNode *>(n);
StringName varname = vn->name;
// Let's see where our argument comes from.
StringName varname;
if (n->type == Node::NODE_TYPE_VARIABLE) {
VariableNode *vn = static_cast<VariableNode *>(n);
varname = vn->name;
} else if (n->type == Node::NODE_TYPE_ARRAY) {
ArrayNode *an = static_cast<ArrayNode *>(n);
varname = an->name;
}
if (shader->uniforms.has(varname)) {
//being sampler, this either comes from a uniform
ShaderNode::Uniform *u = &shader->uniforms[varname];