private ShaderDependencyNode loadNode(Reader reader, String nodeName) {

        ShaderDependencyNode node = new ShaderDependencyNode(nodeName);
        StringBuilder sb = new StringBuilder();
        StringBuilder sbExt = new StringBuilder();

        try (final BufferedReader bufferedReader = new BufferedReader(reader)) {

            String ln;

            if (!nodeName.equals("[main]")) {
                sb.append("// -- begin import ").append(nodeName).append(" --\n");
            }

            while ((ln = bufferedReader.readLine()) != null) {
                String tln = ln.trim();
                if (tln.startsWith("#import ")) {
                    ln = tln.substring(8).trim();
                    if (ln.startsWith("\"") && ln.endsWith("\"") && ln.length() > 3) {
                        // import user code
                        // remove quotes to get filename
                        ln = ln.substring(1, ln.length() - 1);
                        if (ln.equals(nodeName)) {
                            throw new IOException("Node depends on itself.");
                        }

                        // check cache first
                        ShaderDependencyNode dependNode = dependCache.get(ln);

                        if (dependNode == null) {
                            Reader dependNodeReader = assetManager.loadAsset(new ShaderDependencyKey(ln));
                            dependNode = loadNode(dependNodeReader, ln);
                        }

                        node.addDependency(sb.length(), dependNode);
                    }
                } else if (tln.startsWith("#extension ")) {
                    sbExt.append(ln).append('\n');
                } else {
                    sb.append(ln).append('\n');
                }
            }
            if (!nodeName.equals("[main]")) {
                sb.append("// -- end import ").append(nodeName).append(" --\n");
            }
        } catch (final IOException ex) {
            throw new AssetLoadException("Failed to load shader node: " + nodeName, ex);
        }

        node.setSource(sb.toString());
        node.setExtensions(sbExt.toString());
        dependCache.put(nodeName, node);
        return node;
    }
Creates a {@link ShaderDependencyNode} from a stream representing shader code.

@param reader   the reader with shader code
@param nodeName the node name.
@return the shader dependency node
@throws AssetLoadException if we failed to load the shader code.
jme3-core/src/plugins/java/com/jme3/shader/plugins/GLSLLoader.java