/** * declares a variable, embed in a conditional block if needed. * @param source the StringBuilder to use * @param var the variable to declare * @param appendNameSpace true to append the nameSpace + "_" * @param modifier the modifier of the variable (attribute, varying, in , out,...) */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace, String modifier) { declareVariable(source, var, null, appendNameSpace, modifier); }
/** * Declares an attribute * @param source the StringBuilder to use * @param var the variable to declare as an attribute */ protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, false, "attribute"); }
/** * Declares a varying * @param source the StringBuilder to use * @param var the variable to declare as a varying * @param input a boolean set to true if the this varying is an input. * this in not used in this implementation but can be used in overriding * implementation */ protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { declareVariable(source, var, true, "varying"); }
/** * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" * @param source the StringBuilder to use * @param var the variable to declare */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, true, null); }
/** * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" * @param source the StringBuilder to use * @param var the variable to declare * @param value the initialization value to assign the variable */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, String value) { declareVariable(source, var, value, true, null); }
/** * declares a variable, embed in a conditional block if needed * @param source the StringBuilder to use * @param var the variable to declare * @param appendNameSpace true to append the nameSpace + "_" */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace) { declareVariable(source, var, appendNameSpace, null); }
/** * declare a list of uniforms * * @param source the source to append to * @param uniforms the list of uniforms */ protected void generateUniforms(StringBuilder source, List<ShaderNodeVariable> uniforms) { source.append("\n"); for (ShaderNodeVariable var : uniforms) { declareVariable(source, var, false, "uniform"); } }
/** * declare and assign the global position in the vertex shader. * @param info the shader generation info * @param source the shader source being generated */ protected void declareGlobalPosition(ShaderGenerationInfo info, StringBuilder source) { if(inPosTmp.getType().equals(info.getVertexGlobal().getType())){ declareVariable(source, info.getVertexGlobal(), "inPosition"); }else{ declareVariable(source, info.getVertexGlobal(), "vec4(inPosition,1.0)"); } } }
/** * {@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"); }
declareVariable(source, variable, var.getDefaultValue(), true, null); if (!declaredInputs.contains(shaderNode.getName() + "_" + var.getName())) { if (!isVarying(info, v)) { declareVariable(source, v);
/** * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" * @param source the StringBuilder to use * @param var the variable to declare */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, true, null); }
/** * Declares a varying * @param source the StringBuilder to use * @param var the variable to declare as a varying * @param input a boolean set to true if the this varying is an input. * this in not used in this implementation but can be used in overriding * implementation */ protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { declareVariable(source, var, true, "varying"); }
/** * declares a variable, embed in a conditional block if needed * @param source the StringBuilder to use * @param var the variable to declare * @param appendNameSpace true to append the nameSpace + "_" */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace) { declareVariable(source, var, appendNameSpace, null); }
/** * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" * @param source the StringBuilder to use * @param var the variable to declare * @param value the initialization value to assign the variable */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, String value) { declareVariable(source, var, value, true, null); }
/** * declares a variable, embed in a conditional block if needed. * @param source the StringBuilder to use * @param var the variable to declare * @param appendNameSpace true to append the nameSpace + "_" * @param modifier the modifier of the variable (attribute, varying, in , out,...) */ protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace, String modifier) { declareVariable(source, var, null, appendNameSpace, modifier); }
/** * Declares an attribute * @param source the StringBuilder to use * @param var the variable to declare as an attribute */ protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, false, "attribute"); }
/** * declare a list of uniforms * * @param source the source to append to * @param uniforms the list of uniforms */ protected void generateUniforms(StringBuilder source, List<ShaderNodeVariable> uniforms) { source.append("\n"); for (ShaderNodeVariable var : uniforms) { declareVariable(source, var, false, "uniform"); } }
/** * declare and assign the global position in the vertex shader. * @param info the shader generation info * @param source the shader source being generated */ protected void declareGlobalPosition(ShaderGenerationInfo info, StringBuilder source) { if(inPosTmp.getType().equals(info.getVertexGlobal().getType())){ declareVariable(source, info.getVertexGlobal(), "inPosition"); }else{ declareVariable(source, info.getVertexGlobal(), "vec4(inPosition,1.0)"); } } }
/** * {@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"); }
declareVariable(source, variable, var.getDefaultValue(), true, null); if (!declaredInputs.contains(shaderNode.getName() + "_" + var.getName())) { if (!isVarying(info, v)) { declareVariable(source, v);