/** * {@inheritDoc} in glsl 1.5 attributes are prefixed with the "in" keyword * and not the "attribute" keyword */ @Override protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, false, "in"); }
/** * {@inheritDoc} in glsl 1.5 varying are prefixed with the "in" or "out" * keyword and not the "varying" keyword. * * "in" is used for Fragment shader (maybe Geometry shader later) "out" is * used for Vertex shader (maybe Geometry shader later) */ @Override protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { declareVariable(source, var, true, input ? "in" : "out"); }
/** * {@inheritDoc} * * Fragment shader outputs are declared before the "void main(){" with the * "out" keyword. * * after the "void main(){", the vertex output are declared and initialized * and the fragment outputs are declared */ @Override protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) { source.append("\n"); if (type == Shader.ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { declareVariable(source, global, null, true, "out"); } } source.append("\n"); appendIndent(source); source.append("void main(){\n"); indent(); if (type == Shader.ShaderType.Vertex) { declareGlobalPosition(info, source); } else if (type == Shader.ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { initVariable(source, global, "vec4(1.0)"); } } }
/** * {@inheritDoc} in glsl 1.5 attributes are prefixed with the "in" keyword * and not the "attribute" keyword */ @Override protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { declareVariable(source, var, false, "in"); }
/** * {@inheritDoc} in glsl 1.5 varying are prefixed with the "in" or "out" * keyword and not the "varying" keyword. * * "in" is used for Fragment shader (maybe Geometry shader later) "out" is * used for Vertex shader (maybe Geometry shader later) */ @Override protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { declareVariable(source, var, true, input ? "in" : "out"); }
/** * {@inheritDoc} * * Fragment shader outputs are declared before the "void main(){" with the * "out" keyword. * * after the "void main(){", the vertex output are declared and initialized * and the fragment outputs are declared */ @Override protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) { source.append("\n"); if (type == Shader.ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { declareVariable(source, global, null, true, "out"); } } source.append("\n"); appendIndent(source); source.append("void main(){\n"); indent(); if (type == Shader.ShaderType.Vertex) { declareGlobalPosition(info, source); } else if (type == Shader.ShaderType.Fragment) { for (ShaderNodeVariable global : info.getFragmentGlobals()) { initVariable(source, global, "vec4(1.0)"); } } }