/** * returns the shaderpath index according to the version of the generator. * This allow to select the higher version of the shader that the generator * can handle * * @param shaderNode the shaderNode being processed * @param type the shaderType * @return the index of the shader path in ShaderNodeDefinition shadersPath * list * @throws NumberFormatException */ protected int findShaderIndexFromVersion(ShaderNode shaderNode, ShaderType type) throws NumberFormatException { int index = 0; List<String> lang = shaderNode.getDefinition().getShadersLanguage(); int genVersion = Integer.parseInt(getLanguageAndVersion(type).substring(4)); int curVersion = 0; for (int i = 0; i < lang.size(); i++) { int version = Integer.parseInt(lang.get(i).substring(4)); if (version > curVersion && version <= genVersion) { curVersion = version; index = i; } } return index; } }
private void writeShaderNodes(TechniqueDef techniqueDef, Collection<MatParam> matParams, OutputStreamWriter out) throws IOException { out.write(" VertexShaderNodes {\n"); for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { if(shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex){ writeShaderNode(out, shaderNode, matParams); } } out.write(" }\n\n"); out.write(" FragmentShaderNodes {\n"); for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { if(shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment){ writeShaderNode(out, shaderNode, matParams); } } out.write(" }\n\n"); }
out.write(shaderNode.getDefinition().getName()); out.write(": "); out.write(shaderNode.getDefinition().getPath()); out.write("\n");
continue; if (shaderNode.getDefinition().getType() == type) { int index = findShaderIndexFromVersion(shaderNode, type); String shaderPath = shaderNode.getDefinition().getShadersPath().get(index); Map<String, String> sources = (Map<String, String>) assetManager.loadAsset(new ShaderAssetKey(shaderPath, false)); String loadedSource = sources.get("[main]");
variable.setShaderOutput(true); final ShaderNodeDefinition nodeDefinition = node.getDefinition(); final ShaderNodeDefinition currentDefinition = shaderNode.getDefinition();
final ShaderNodeDefinition definition = shaderNode.getDefinition(); final ShaderNodeVariable left = mapping.getLeftVariable(); final ShaderNodeVariable right = mapping.getRightVariable();
/** * Stores a global output. * * @param var the variable to store. * @param varStatement the statement being read. * @throws MatParseException if we have duplicates of a global vertex output variable. */ public void storeGlobal(ShaderNodeVariable var, Statement varStatement) throws MatParseException { var.setShaderOutput(true); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); final ShaderNodeDefinition definition = shaderNode.getDefinition(); if (definition.getType() == ShaderType.Vertex) { ShaderNodeVariable global = generationInfo.getVertexGlobal(); if (global != null) { if (!global.getName().equals(var.getName())) { throw new MatParseException("A global output is already defined for the vertex shader: " + global.getName() + ". vertex shader can only have one global output", varStatement); } } else { generationInfo.setVertexGlobal(var); } } else if (definition.getType() == ShaderType.Fragment) { storeVariable(var, generationInfo.getFragmentGlobals()); } }
final ShaderNodeDefinition definition = shaderNode.getDefinition();
assertEquals(sh1.getName(), sh2.getName()); assertEquals(sh1.getCondition(), sh2.getCondition()); assertEquals(sh1.getDefinition().getName(), sh2.getDefinition().getName()); for (int i1 = 0; i1 < sh1.getInputMapping().size(); i1++) { VariableMapping im1 = sh1.getInputMapping().get(i);
final ShaderNodeDefinition definition = shaderNode.getDefinition(); final ShaderNodeVariable left = mapping.getLeftVariable(); final ShaderNodeVariable right = mapping.getRightVariable(); ShaderNodeVariable var = findNodeOutput(node.getDefinition().getOutputs(), right.getName());
/** * returns the shaderpath index according to the version of the generator. * This allow to select the higher version of the shader that the generator * can handle * * @param shaderNode the shaderNode being processed * @param type the shaderType * @return the index of the shader path in ShaderNodeDefinition shadersPath * list * @throws NumberFormatException */ protected int findShaderIndexFromVersion(ShaderNode shaderNode, ShaderType type) throws NumberFormatException { int index = 0; List<String> lang = shaderNode.getDefinition().getShadersLanguage(); int genVersion = Integer.parseInt(getLanguageAndVersion(type).substring(4)); int curVersion = 0; for (int i = 0; i < lang.size(); i++) { int version = Integer.parseInt(lang.get(i).substring(4)); if (version > curVersion && version <= genVersion) { curVersion = version; index = i; } } return index; } }
private void writeShaderNodes(TechniqueDef techniqueDef, Collection<MatParam> matParams, OutputStreamWriter out) throws IOException { out.write(" VertexShaderNodes {\n"); for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { if(shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex){ writeShaderNode(out, shaderNode, matParams); } } out.write(" }\n\n"); out.write(" FragmentShaderNodes {\n"); for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { if(shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment){ writeShaderNode(out, shaderNode, matParams); } } out.write(" }\n\n"); }
private void writeShaderNode( OutputStreamWriter out, ShaderNode shaderNode, Collection<MatParam> matParams) throws IOException { out.write(" ShaderNode "); out.write(shaderNode.getName()); out.write(" {\n"); if (shaderNode.getCondition() != null){ out.write(" Condition: "); out.write(formatCondition(shaderNode.getCondition(), matParams)); out.write("\n"); } out.write(" Definition: "); out.write(shaderNode.getDefinition().getName()); out.write(": "); out.write(shaderNode.getDefinition().getPath()); out.write("\n"); out.write(" InputMappings {\n"); for (VariableMapping mapping : shaderNode.getInputMapping()) { writeVariableMapping(out, shaderNode, mapping, matParams); } out.write(" }\n"); out.write(" OutputMappings {\n"); for (VariableMapping mapping : shaderNode.getOutputMapping()) { writeVariableMapping(out, shaderNode, mapping, matParams); } out.write(" }\n"); out.write(" }\n"); }
continue; if (shaderNode.getDefinition().getType() == type) { int index = findShaderIndexFromVersion(shaderNode, type); String shaderPath = shaderNode.getDefinition().getShadersPath().get(index); Map<String, String> sources = (Map<String, String>) assetManager.loadAsset(new ShaderAssetKey(shaderPath, false)); String loadedSource = sources.get("[main]");
variable.setShaderOutput(true); final ShaderNodeDefinition nodeDefinition = node.getDefinition(); final ShaderNodeDefinition currentDefinition = shaderNode.getDefinition();
/** * stores a global output * * @param var the variable to store * @param statement1 the statement being read * @throws IOException */ public void storeGlobal(ShaderNodeVariable var, Statement statement1) throws IOException { var.setShaderOutput(true); if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { ShaderNodeVariable global = techniqueDef.getShaderGenerationInfo().getVertexGlobal(); if (global != null) { if (!global.getName().equals(var.getName())) { throw new MatParseException("A global output is already defined for the vertex shader: " + global.getName() + ". vertex shader can only have one global output", statement1); } } else { techniqueDef.getShaderGenerationInfo().setVertexGlobal(var); } } else if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) { storeVariable(var, techniqueDef.getShaderGenerationInfo().getFragmentGlobals()); } }
if (!updateVariableFromList(right, shaderNode.getDefinition().getOutputs())) { throw new MatParseException(right.getName() + " is not an output variable of " + shaderNode.getDefinition().getName(), statement1);
if (!updateVariableFromList(left, shaderNode.getDefinition().getInputs())) { throw new MatParseException(left.getName() + " is not an input variable of " + shaderNode.getDefinition().getName(), statement1); if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) { throw new MatParseException("Cannot have an attribute as input in a fragment shader" + right.getName(), statement1); throw new MatParseException("Could not find a Material Parameter named " + right.getName(), statement1); if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { if (updateRightFromUniforms(param, mapping, vertexDeclaredUniforms, statement1)) { updateMaterialTextureType(statement1, mapping, left, param); throw new MatParseException("Could not find a World Parameter named " + right.getName(), statement1); if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { if (updateRightFromUniforms(worldParam, mapping, vertexDeclaredUniforms)) { storeVertexUniform(mapping.getRightVariable()); throw new MatParseException("Undeclared node" + right.getNameSpace() + ". Make sure this node is declared before the current node", statement1); ShaderNodeVariable var = findNodeOutput(node.getDefinition().getOutputs(), right.getName()); if (var == null) { throw new MatParseException("Cannot find output variable" + right.getName() + " form ShaderNode " + node.getName(), statement1);
final ShaderNodeDefinition definition = shaderNode.getDefinition();