protected void computeConditions() { updateConditions(vertexDeclaredUniforms); updateConditions(fragmentDeclaredUniforms); updateConditions(varyings); for (DeclaredVariable v : varyings.values()) { for (ShaderNode sn : techniqueDef.getShaderNodes()) { if (sn.getDefinition().getType() == Shader.ShaderType.Vertex) { for (VariableMapping mapping : sn.getInputMapping()) { if (mapping.getLeftVariable().equals(v.var)) { if (mapping.getCondition() == null || v.var.getCondition() == null) { mapping.setCondition(v.var.getCondition()); } else { mapping.setCondition( "(" + mapping.getCondition() + ") || (" + v.var.getCondition() + ")"); } } } } } } updateConditions(attributes); // updateConditions(fragmentGlobals); // vertexGlobal.makeCondition(); }
public void makeCondition() { var.setCondition(null); for (ShaderNode node : nodes) { String condition = null; for (VariableMapping mapping : node.getInputMapping()) { if (mapping.getRightVariable().equals(var)) { if (mapping.getCondition() == null) { condition = null; break; } if (condition == null) { condition = "(" + mapping.getCondition() + ")"; } else { if (!condition.contains(mapping.getCondition())) { condition = condition + " || (" + mapping.getCondition() + ")"; } } } } if (node.getCondition() == null && condition == null) { var.setCondition(null); return; } if (node.getCondition() != null) { if (condition == null) { condition = node.getCondition(); } else { if (!condition.contains(node.getCondition())) { condition = "(" + node.getCondition() + ") && (" + condition + ")"; } } } if (var.getCondition() == null) { var.setCondition(condition); } else { if (!var.getCondition().contains(condition)) { var.setCondition("(" + var.getCondition() + ") || (" + condition + ")"); } } } }