/** * Reads alist of ShaderNodes * * @param statements the list of statements to read * @throws IOException */ public void readNodes(List<Statement> statements) throws IOException { if (techniqueDef.getShaderNodes() == null) { techniqueDef.setShaderNodes(new ArrayList<ShaderNode>()); techniqueDef.setShaderGenerationInfo(new ShaderGenerationInfo()); } for (Statement statement : statements) { String[] split = statement.getLine().split("[ \\{]"); if (statement.getLine().startsWith("ShaderNode ")) { String name = statement.getLine().substring("ShaderNode".length()).trim(); if (nodes == null) { nodes = new HashMap<String, ShaderNode>(); } if (!nodes.containsKey(name)) { shaderNode = new ShaderNode(); shaderNode.setName(name); techniqueDef.getShaderGenerationInfo().getUnusedNodes().add(name); readShaderNode(statement.getContents()); nodes.put(name, shaderNode); techniqueDef.getShaderNodes().add(shaderNode); } else { throw new MatParseException("ShaderNode " + name + " is already defined", statement); } } else { throw new MatParseException("ShaderNode", split[0], statement); } } }
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(); }