Search in sources :

Example 1 with ShaderNodeVariable

use of com.jme3.shader.ShaderNodeVariable in project jmonkeyengine by jMonkeyEngine.

the class ShaderNodeDefinition method read.

/**
     * jme serialization (not used)
     *
     * @param im the importer
     * @throws IOException
     */
@Override
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = (InputCapsule) im.getCapsule(this);
    name = ic.readString("name", "");
    String[] str = ic.readStringArray("shadersLanguage", null);
    if (str != null) {
        shadersLanguage = Arrays.asList(str);
    } else {
        shadersLanguage = new ArrayList<String>();
    }
    str = ic.readStringArray("shadersPath", null);
    if (str != null) {
        shadersPath = Arrays.asList(str);
    } else {
        shadersPath = new ArrayList<String>();
    }
    type = ic.readEnum("type", Shader.ShaderType.class, null);
    inputs = (List<ShaderNodeVariable>) ic.readSavableArrayList("inputs", new ArrayList<ShaderNodeVariable>());
    outputs = (List<ShaderNodeVariable>) ic.readSavableArrayList("outputs", new ArrayList<ShaderNodeVariable>());
}
Also used : InputCapsule(com.jme3.export.InputCapsule) ShaderType(com.jme3.shader.Shader.ShaderType)

Example 2 with ShaderNodeVariable

use of com.jme3.shader.ShaderNodeVariable in project jmonkeyengine by jMonkeyEngine.

the class VariableMapping method read.

/**
     * jme serialization (not used)
     *
     * @param im the importer
     * @throws IOException
     */
@Override
public void read(JmeImporter im) throws IOException {
    InputCapsule ic = (InputCapsule) im.getCapsule(this);
    leftVariable = (ShaderNodeVariable) ic.readSavable("leftVariable", null);
    rightVariable = (ShaderNodeVariable) ic.readSavable("rightVariable", null);
    condition = ic.readString("condition", "");
    leftSwizzling = ic.readString("leftSwizzling", "");
    rightSwizzling = ic.readString("rightSwizzling", "");
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 3 with ShaderNodeVariable

use of com.jme3.shader.ShaderNodeVariable in project jmonkeyengine by jMonkeyEngine.

the class ShaderGenerationInfo method clone.

@Override
protected ShaderGenerationInfo clone() throws CloneNotSupportedException {
    ShaderGenerationInfo clone = (ShaderGenerationInfo) super.clone();
    for (ShaderNodeVariable attribute : attributes) {
        clone.attributes.add(attribute.clone());
    }
    for (ShaderNodeVariable uniform : vertexUniforms) {
        clone.vertexUniforms.add(uniform.clone());
    }
    clone.vertexGlobal = vertexGlobal.clone();
    for (ShaderNodeVariable varying : varyings) {
        clone.varyings.add(varying.clone());
    }
    for (ShaderNodeVariable uniform : fragmentUniforms) {
        clone.fragmentUniforms.add(uniform.clone());
    }
    for (ShaderNodeVariable globals : fragmentGlobals) {
        clone.fragmentGlobals.add(globals.clone());
    }
    clone.unusedNodes.addAll(unusedNodes);
    return clone;
}
Also used : ShaderNodeVariable(com.jme3.shader.ShaderNodeVariable)

Example 4 with ShaderNodeVariable

use of com.jme3.shader.ShaderNodeVariable in project jmonkeyengine by jMonkeyEngine.

the class ShaderGenerationInfo method write.

@Override
public void write(JmeExporter ex) throws IOException {
    OutputCapsule oc = ex.getCapsule(this);
    oc.writeSavableArrayList((ArrayList) attributes, "attributes", new ArrayList<ShaderNodeVariable>());
    oc.writeSavableArrayList((ArrayList) vertexUniforms, "vertexUniforms", new ArrayList<ShaderNodeVariable>());
    oc.writeSavableArrayList((ArrayList) varyings, "varyings", new ArrayList<ShaderNodeVariable>());
    oc.writeSavableArrayList((ArrayList) fragmentUniforms, "fragmentUniforms", new ArrayList<ShaderNodeVariable>());
    oc.writeSavableArrayList((ArrayList) fragmentGlobals, "fragmentGlobals", new ArrayList<ShaderNodeVariable>());
    oc.write(vertexGlobal, "vertexGlobal", null);
}
Also used : OutputCapsule(com.jme3.export.OutputCapsule) ShaderNodeVariable(com.jme3.shader.ShaderNodeVariable)

Example 5 with ShaderNodeVariable

use of com.jme3.shader.ShaderNodeVariable in project jmonkeyengine by jMonkeyEngine.

the class ShaderNodeLoaderDelegate method updateRightFromUniforms.

/**
     * updates the right variable of the given mapping from a UniformBinding (a
     * WorldParam) it checks if the uniform hasn't already been loaded, add it
     * to the maps if not.
     *
     * @param param the WorldParam UniformBinding
     * @param mapping the mapping
     * @param map the map of uniforms to search into
     * @return true if the param was added to the map
     */
protected boolean updateRightFromUniforms(UniformBinding param, VariableMapping mapping, Map<String, DeclaredVariable> map) {
    ShaderNodeVariable right = mapping.getRightVariable();
    String name = "g_" + param.toString();
    DeclaredVariable dv = map.get(name);
    if (dv == null) {
        right.setType(param.getGlslType());
        right.setName(name);
        dv = new DeclaredVariable(right);
        map.put(right.getName(), dv);
        dv.addNode(shaderNode);
        mapping.setRightVariable(right);
        return true;
    }
    dv.addNode(shaderNode);
    mapping.setRightVariable(dv.var);
    return false;
}
Also used : ShaderNodeVariable(com.jme3.shader.ShaderNodeVariable)

Aggregations

ShaderNodeVariable (com.jme3.shader.ShaderNodeVariable)8 VariableMapping (com.jme3.shader.VariableMapping)4 InputCapsule (com.jme3.export.InputCapsule)3 AssetNotFoundException (com.jme3.asset.AssetNotFoundException)2 OutputCapsule (com.jme3.export.OutputCapsule)2 MatParam (com.jme3.material.MatParam)2 IOException (java.io.IOException)2 ShaderType (com.jme3.shader.Shader.ShaderType)1 ShaderNode (com.jme3.shader.ShaderNode)1 UniformBinding (com.jme3.shader.UniformBinding)1 ArrayList (java.util.ArrayList)1