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>());
}
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", "");
}
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;
}
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);
}
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;
}
Aggregations