/** * Ends a conditional block * @param condition the block condition * @param source the StringBuilder to use */ protected void endCondition(String condition, StringBuilder source) { if (condition != null) { unIndent(); appendIndent(source); source.append("#endif\n"); } }
/** * Starts a conditional block * @param condition the block condition * @param source the StringBuilder to use */ protected void startCondition(String condition, StringBuilder source) { if (condition != null) { appendIndent(source); source.append("#if "); source.append(condition); source.append("\n"); indent(); } }
/** * Appends a comment to the generated code * @param source the StringBuilder to use * @param shaderNode the shader node being processed (to append its name) * @param comment the comment to append */ protected void comment(StringBuilder source, ShaderNode shaderNode, String comment) { appendIndent(source); source.append("//"); source.append(shaderNode.getName()); source.append(" : "); source.append(comment); source.append("\n"); }
/** * Appends an output assignment to a shader globalOutputName = * nameSpace_varName; * * @param source the source StringBuilter to append the code. * @param globalOutputName the name of the global output (can be gl_Position * or gl_FragColor etc...). * @param var the variable to assign to the output. */ protected void appendOutput(StringBuilder source, String globalOutputName, ShaderNodeVariable var) { appendIndent(source); source.append(globalOutputName); source.append(" = "); source.append(var.getNameSpace()); source.append("_"); source.append(var.getName()); source.append(";\n"); }
/** * {@inheritDoc} * * Shader outputs are declared and initialized inside the main section */ @Override protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { source.append("\n"); source.append("void main() {\n"); indent(); appendIndent(source); if (type == ShaderType.Vertex) { declareGlobalPosition(info, source); } else if (type == ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { declareVariable(source, global, "vec4(1.0)"); } } source.append("\n"); }
appendIndent(source); if (modifier != null) { source.append(modifier);
appendIndent(source); source.append("}\n");
appendIndent(source); if (!leftVariable.isShaderOutput() && declare) { source.append(leftVariable.getType()); source.append(leftVariable.getType()); source.append("(0.0);\n"); appendIndent(source);
/** * Ends a conditional block * @param condition the block condition * @param source the StringBuilder to use */ protected void endCondition(String condition, StringBuilder source) { if (condition != null) { unIndent(); appendIndent(source); source.append("#endif\n"); } }
/** * Starts a conditional block * @param condition the block condition * @param source the StringBuilder to use */ protected void startCondition(String condition, StringBuilder source) { if (condition != null) { appendIndent(source); source.append("#if "); source.append(condition); source.append("\n"); indent(); } }
/** * Appends a comment to the generated code * @param source the StringBuilder to use * @param shaderNode the shader node being processed (to append its name) * @param comment the comment to append */ protected void comment(StringBuilder source, ShaderNode shaderNode, String comment) { appendIndent(source); source.append("//"); source.append(shaderNode.getName()); source.append(" : "); source.append(comment); source.append("\n"); }
/** * Appends an output assignment to a shader globalOutputName = * nameSpace_varName; * * @param source the source StringBuilter to append the code. * @param globalOutputName the name of the global output (can be gl_Position * or gl_FragColor etc...). * @param var the variable to assign to the output. */ protected void appendOutput(StringBuilder source, String globalOutputName, ShaderNodeVariable var) { appendIndent(source); source.append(globalOutputName); source.append(" = "); source.append(var.getNameSpace()); source.append("_"); source.append(var.getName()); source.append(";\n"); }
/** * {@inheritDoc} * * Shader outputs are declared and initialized inside the main section */ @Override protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { source.append("\n"); source.append("void main() {\n"); indent(); appendIndent(source); if (type == ShaderType.Vertex) { declareGlobalPosition(info, source); } else if (type == ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { declareVariable(source, global, "vec4(1.0)"); } } source.append("\n"); }
appendIndent(source); if (modifier != null) { source.append(modifier);
appendIndent(source); source.append("}\n");
appendIndent(source); if (!mapping.getLeftVariable().isShaderOutput()) { source.append(mapping.getLeftVariable().getType()); source.append(mapping.getLeftVariable().getType()); source.append("(0.0);\n"); appendIndent(source);