Allow using vertex-stage varying in both fragment and light

This commit is contained in:
Yuri Roubinsky 2021-07-22 11:41:02 +03:00
parent a4c863791e
commit 17b462cc5f
2 changed files with 6 additions and 22 deletions

View file

@ -3324,8 +3324,7 @@ bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, St
p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT; p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT;
} }
break; break;
case ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT: case ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT_LIGHT:
case ShaderNode::Varying::STAGE_VERTEX_TO_LIGHT:
case ShaderNode::Varying::STAGE_VERTEX: case ShaderNode::Varying::STAGE_VERTEX:
if (current_function == varying_function_names.fragment) { if (current_function == varying_function_names.fragment) {
*r_message = RTR("Varyings which assigned in 'vertex' function may not be reassigned in 'fragment' or 'light'."); *r_message = RTR("Varyings which assigned in 'vertex' function may not be reassigned in 'fragment' or 'light'.");
@ -3351,10 +3350,8 @@ bool ShaderLanguage::_validate_varying_using(ShaderNode::Varying &p_varying, Str
*r_message = RTR("Varying must be assigned before using!"); *r_message = RTR("Varying must be assigned before using!");
return false; return false;
case ShaderNode::Varying::STAGE_VERTEX: case ShaderNode::Varying::STAGE_VERTEX:
if (current_function == varying_function_names.fragment) { if (current_function == varying_function_names.fragment || current_function == varying_function_names.light) {
p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT; p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_FRAGMENT_LIGHT;
} else if (current_function == varying_function_names.light) {
p_varying.stage = ShaderNode::Varying::STAGE_VERTEX_TO_LIGHT;
} }
break; break;
case ShaderNode::Varying::STAGE_FRAGMENT: case ShaderNode::Varying::STAGE_FRAGMENT:
@ -3362,18 +3359,6 @@ bool ShaderLanguage::_validate_varying_using(ShaderNode::Varying &p_varying, Str
p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT_TO_LIGHT; p_varying.stage = ShaderNode::Varying::STAGE_FRAGMENT_TO_LIGHT;
} }
break; 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: default:
break; break;
} }

View file

@ -646,10 +646,9 @@ public:
struct Varying { struct Varying {
enum Stage { enum Stage {
STAGE_UNKNOWN, STAGE_UNKNOWN,
STAGE_VERTEX, // transition stage to STAGE_VERTEX_TO_FRAGMENT or STAGE_VERTEX_TO_LIGHT, emits error if they are not used 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 error 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, STAGE_VERTEX_TO_FRAGMENT_LIGHT,
STAGE_VERTEX_TO_LIGHT,
STAGE_FRAGMENT_TO_LIGHT, STAGE_FRAGMENT_TO_LIGHT,
}; };