use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class OneMinusShaderNodeBuilder method buildCommonNode.
@Override
protected ObjectMap<String, ? extends FieldOutput> buildCommonNode(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, FieldOutput> inputs, ObjectSet<String> producedOutputs, CommonShaderBuilder commonShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
FieldOutput inputValue = inputs.get("input");
ShaderFieldType resultType = inputValue.getFieldType();
commonShaderBuilder.addMainLine("// One minus node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = 1.0 - " + inputValue.getRepresentation() + ";");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class CeilingShaderNodeBuilder method buildCommonNode.
@Override
protected ObjectMap<String, ? extends FieldOutput> buildCommonNode(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, FieldOutput> inputs, ObjectSet<String> producedOutputs, CommonShaderBuilder commonShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
FieldOutput inputValue = inputs.get("input");
ShaderFieldType resultType = inputValue.getFieldType();
commonShaderBuilder.addMainLine("// Ceiling node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = ceil(" + inputValue.getRepresentation() + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class SignShaderNodeBuilder method buildCommonNode.
@Override
protected ObjectMap<String, ? extends FieldOutput> buildCommonNode(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, FieldOutput> inputs, ObjectSet<String> producedOutputs, CommonShaderBuilder commonShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
FieldOutput inputValue = inputs.get("input");
ShaderFieldType resultType = inputValue.getFieldType();
commonShaderBuilder.addMainLine("// Sign node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = sign(" + inputValue.getRepresentation() + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class DitherColorShaderNodeBuilder method buildCommonNode.
@Override
protected ObjectMap<String, ? extends FieldOutput> buildCommonNode(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, FieldOutput> inputs, ObjectSet<String> producedOutputs, CommonShaderBuilder commonShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
FieldOutput colorValue = inputs.get("color");
FieldOutput positionValue = inputs.get("position");
FieldOutput pixelSizeValue = inputs.get("pixelSize");
commonShaderBuilder.addMainLine("// Dither color node");
String name = "result_" + nodeId;
String resultType = ShaderFieldType.Vector4;
int ditherSize = data.getInt("ditherSize", 4);
loadFragmentIfNotDefined(commonShaderBuilder, "dither/dither" + ditherSize);
String getDitherColorFunctionName = "getDitherColor_" + nodeId;
String getDitherColorFunction = createGetDitherColorFunction(getDitherColorFunctionName, ditherSize);
commonShaderBuilder.addFunction(getDitherColorFunctionName, getDitherColorFunction);
commonShaderBuilder.addMainLine("vec4 " + name + " = " + getDitherColorFunctionName + "(" + positionValue.getRepresentation() + ", " + pixelSizeValue.getRepresentation() + ", " + colorValue.getRepresentation() + ");\n");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class AddShaderNodeBuilder method buildAddCommonNode.
private ObjectMap<String, ? extends FieldOutput> buildAddCommonNode(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, Array<FieldOutput>> inputArrays, ObjectSet<String> producedOutputs, CommonShaderBuilder commonShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
Array<FieldOutput> inputs = inputArrays.get("inputs");
ShaderFieldType resultType = determineOutputType(inputs);
commonShaderBuilder.addMainLine("// Add node");
String name = "result_" + nodeId;
StringBuilder additionText = new StringBuilder();
for (FieldOutput input : inputs) {
additionText.append(" + ");
additionText.append(input.getRepresentation());
}
additionText.replace(0, 3, "");
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = " + additionText + ";");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
Aggregations