diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-26 12:17:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-26 12:17:49 +0200 |
commit | a8fcfbf029b10bb861212ff8de4fb9f0062ed04c (patch) | |
tree | dd1d9b993d7bebb2e832b56870703167815da2f3 /servers | |
parent | 9b9e09f6759b619d89afa5e75494f3a1d2085dc4 (diff) | |
parent | 17b462cc5f455659ac06da9504bb7d302e47cde3 (diff) |
Merge pull request #50729 from Chaosus/shader_varying_enchancements2
Allow using vertex-stage varying in both `fragment` and `light` functions
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/shader_language.cpp | 21 | ||||
-rw-r--r-- | servers/rendering/shader_language.h | 7 |
2 files changed, 6 insertions, 22 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index ed7406db86..47d10f91a7 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -3326,8 +3326,7 @@ bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, St p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT; } break; - case ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT: - case ShaderNode::Varying::STAGE_VERTEX_TO_LIGHT: + case ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT_LIGHT: case ShaderNode::Varying::STAGE_VERTEX: if (current_function == varying_function_names.fragment) { *r_message = RTR("Varyings which assigned in 'vertex' function may not be reassigned in 'fragment' or 'light'."); @@ -3356,10 +3355,8 @@ bool ShaderLanguage::_validate_varying_using(ShaderNode::Varying &p_varying, Str unknown_varying_usages.push_back(usage); break; case ShaderNode::Varying::STAGE_VERTEX: - if (current_function == varying_function_names.fragment) { - p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT; - } else if (current_function == varying_function_names.light) { - p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_LIGHT; + if (current_function == varying_function_names.fragment || current_function == varying_function_names.light) { + p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT_LIGHT; } break; case ShaderNode::Varying::STAGE_FRAGMENT: @@ -3367,18 +3364,6 @@ bool ShaderLanguage::_validate_varying_using(ShaderNode::Varying &p_varying, Str p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT_TO_LIGHT; } break; - case ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT: - if (current_function == varying_function_names.light) { - *r_message = RTR("Varying must only be used in two different stages, which can be 'vertex' 'fragment' and 'light'"); - return false; - } - break; - case ShaderNode::Varying::STAGE_VERTEX_TO_LIGHT: - if (current_function == varying_function_names.fragment) { - *r_message = RTR("Varying must only be used in two different stages, which can be 'vertex' 'fragment' and 'light'"); - return false; - } - break; default: break; } diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index f27c4aba90..59c6e19338 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -646,10 +646,9 @@ public: struct Varying { enum Stage { STAGE_UNKNOWN, - STAGE_VERTEX, // transition stage to STAGE_VERTEX_TO_FRAGMENT or STAGE_VERTEX_TO_LIGHT, emits error if they are not used - STAGE_FRAGMENT, // transition stage to STAGE_FRAGMENT_TO_LIGHT, emits error if it's not used - STAGE_VERTEX_TO_FRAGMENT, - STAGE_VERTEX_TO_LIGHT, + STAGE_VERTEX, // transition stage to STAGE_VERTEX_TO_FRAGMENT_LIGHT, emits warning if it's not used + STAGE_FRAGMENT, // transition stage to STAGE_FRAGMENT_TO_LIGHT, emits warning if it's not used + STAGE_VERTEX_TO_FRAGMENT_LIGHT, STAGE_FRAGMENT_TO_LIGHT, }; |