diff options
author | Jesse Dubay <jesse@jessedubay.com> | 2019-05-11 10:41:13 -0700 |
---|---|---|
committer | Jesse Dubay <jesse@jessedubay.com> | 2019-05-11 11:01:09 -0700 |
commit | 1b9d26765f88d37ecd21dd3ce7fb1fecda15f4d9 (patch) | |
tree | 2fbfa5d5288f8caa3cdf17cf514e1b117f2aeabc | |
parent | 89c37dae490b8072a0997bbcab739c45ecb3044d (diff) |
Allow constructing larger data types by swizzling
GLSL allows the construction of larger data types by swizzling smaller
ones, but Godot shading language treated this as an error:
vec2 test2 = vec2(0.0, 1.0);
vec3 test3 = test2.xxx; // error: Invalid member for vec2 expression
This commit updates the expression parser for the 2 and 3-component data
types accordingly.
Fixes #10496
-rw-r--r-- | servers/visual/shader_language.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 33714a79b2..73f8da7c5e 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -2968,6 +2968,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons member_type = DataType(dt - 1); } else if (l == 2) { member_type = dt; + } else if (l == 3) { + member_type = DataType(dt + 1); + } else if (l == 4) { + member_type = DataType(dt + 2); } else { ok = false; break; @@ -3001,6 +3005,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons member_type = DataType(dt - 1); } else if (l == 3) { member_type = dt; + } else if (l == 4) { + member_type = DataType(dt + 1); } else { ok = false; break; |