@Override
    protected void generateNodeMainSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info) {

        nodeSource = updateDefinesName(nodeSource, shaderNode);
        source.append("\n");
        comment(source, shaderNode, "Begin");
        startCondition(shaderNode.getCondition(), source);

        final List<String> declaredInputs = new ArrayList<>();

        // Declaring variables with default values first
        final ShaderNodeDefinition definition = shaderNode.getDefinition();

        for (final ShaderNodeVariable var : definition.getInputs()) {

            if (var.getType().startsWith("sampler")) {
                continue;
            }

            final String fullName = shaderNode.getName() + "_" + var.getName();

            final ShaderNodeVariable variable = new ShaderNodeVariable(var.getType(), shaderNode.getName(),
                    var.getName(), var.getMultiplicity());

            if (!isVarying(info, variable)) {
                declareVariable(source, variable, var.getDefaultValue(), true, null);
            }

            nodeSource = replaceVariableName(nodeSource, variable);
            declaredInputs.add(fullName);
        }

        for (VariableMapping mapping : shaderNode.getInputMapping()) {

            final ShaderNodeVariable rightVariable = mapping.getRightVariable();
            final ShaderNodeVariable leftVariable = mapping.getLeftVariable();

            String newName = shaderNode.getName() + "_" + leftVariable.getName();
            boolean isDeclared = declaredInputs.contains(newName);
            //Variables fed with a sampler matparam or world param are replaced by the matparam itself
            //It avoids issue with samplers that have to be uniforms.
            if (rightVariable != null && isWorldOrMaterialParam(rightVariable) && rightVariable.getType().startsWith("sampler")) {
                nodeSource = replace(nodeSource, leftVariable, rightVariable.getPrefix() + rightVariable.getName());
            } else {

                if (leftVariable.getType().startsWith("sampler")) {
                    throw new IllegalArgumentException("a Sampler must be a uniform");
                }
                map(mapping, source, !isDeclared);
            }

            if (!isDeclared) {
                nodeSource = replace(nodeSource, leftVariable, newName);
                declaredInputs.add(newName);
            }
        }



        for (ShaderNodeVariable var : definition.getOutputs()) {
            ShaderNodeVariable v = new ShaderNodeVariable(var.getType(), shaderNode.getName(), var.getName(), var.getMultiplicity());
            if (!declaredInputs.contains(shaderNode.getName() + "_" + var.getName())) {
                if (!isVarying(info, v)) {
                    declareVariable(source, v);
                }
                nodeSource = replaceVariableName(nodeSource, v);
            }
        }
        
        source.append(nodeSource);
   
        for (VariableMapping mapping : shaderNode.getOutputMapping()) {
            map(mapping, source, true);
        }
        endCondition(shaderNode.getCondition(), source);
        comment(source, shaderNode, "End");
    }
{@inheritDoc}

This method does things in the following order:

1. declaring and mapping input<br>
variables : variable replaced with MatParams or WorldParams that are Samplers are not
declared and are replaced by the param actual name in the code. For others
variables, the name space is appended with a "_" before the variable name
in the code to avoid names collision between shaderNodes. <br>

2. declaring output variables : <br>
variables are declared if they were not already
declared as input (inputs can also be outputs) or if they are not
declared as varyings. The variable name is also prefixed with the s=name
space and "_" in the shaderNode code <br>

3. append of the actual ShaderNode code <br>

4. mapping outputs to global output if needed<br>


<br>
All of this is embedded in a #if conditional statement if necessary.
jme3-core/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java