diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-25 18:02:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 18:02:38 +0200 |
commit | 33bf609d7909dc5d76a47fdea573e3b693c92a4f (patch) | |
tree | a627d2234f15e269c375c7e21ddb0811d724c9ba /servers | |
parent | 03f6a9d88ef3926e1d684918353c24307d829eb4 (diff) | |
parent | d4a10e7e04bdce0ce9aaa853d7d06da566b31363 (diff) |
Merge pull request #64820 from Chaosus/shader_fix_varyings
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/shader_language.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index cab92e6e20..2bbc5e4dfb 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -5377,6 +5377,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } _set_tkpos(prev_pos); + ShaderNode::Varying &var = shader->varyings[identifier]; String error; if (is_token_operator_assign(next_token.type)) { if (!_validate_varying_assign(shader->varyings[identifier], &error)) { @@ -5384,8 +5385,6 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons return nullptr; } } else { - ShaderNode::Varying &var = shader->varyings[identifier]; - switch (var.stage) { case ShaderNode::Varying::STAGE_VERTEX: if (current_function == varying_function_names.fragment || current_function == varying_function_names.light) { @@ -5401,6 +5400,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons break; } } + + if ((var.stage != ShaderNode::Varying::STAGE_FRAGMENT && var.stage != ShaderNode::Varying::STAGE_FRAGMENT_TO_LIGHT) && var.type < TYPE_FLOAT && var.interpolation != INTERPOLATION_FLAT) { + _set_tkpos(var.tkpos); + _set_error(RTR("Varying with integer data type must be declared with `flat` interpolation qualifier.")); + return nullptr; + } } if (ident_type == IDENTIFIER_FUNCTION) { @@ -8299,8 +8304,8 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f return ERR_PARSE_ERROR; } - if (!is_uniform && (type < TYPE_FLOAT || type > TYPE_MAT4)) { - _set_error(RTR("Invalid type for varying, only 'float', 'vec2', 'vec3', 'vec4', 'mat2', 'mat3', 'mat4', or arrays of these types are allowed.")); + if (!is_uniform && type > TYPE_MAT4) { + _set_error(RTR("Invalid data type for varying.")); return ERR_PARSE_ERROR; } |