use of com.gempukku.libgdx.graph.shader.field.ShaderFieldType in project gdx-graph by MarcinSc.
the class SubtractShaderNodeBuilder method determineOutputType.
private ShaderFieldType determineOutputType(FieldOutput a, FieldOutput b) {
ShaderFieldType aType = a.getFieldType();
ShaderFieldType bType = b.getFieldType();
if (aType.getName().equals(ShaderFieldType.Float))
return bType;
if (bType.getName().equals(ShaderFieldType.Float))
return aType;
if (aType != bType)
throw new IllegalStateException("Invalid mix of input field types");
return aType;
}
use of com.gempukku.libgdx.graph.shader.field.ShaderFieldType in project gdx-graph by MarcinSc.
the class ConditionalShaderNodeBuilder 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 a = inputs.get("a");
FieldOutput b = inputs.get("b");
FieldOutput aTrue = inputs.get("true");
FieldOutput aFalse = inputs.get("false");
String operation = data.getString("operation");
String aggregate = data.getString("aggregate");
ShaderFieldType resultType = aTrue.getFieldType();
commonShaderBuilder.addMainLine("// Conditional node");
String name = "result_" + nodeId;
if (a.getFieldType().getName().equals(ShaderFieldType.Float)) {
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = (" + a.getRepresentation() + " " + operation + " " + b.getRepresentation() + ") ? " + aTrue.getRepresentation() + " : " + aFalse.getRepresentation() + ";");
} else {
String function = getFunction(operation);
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = " + aggregate + "(" + function + "(" + a.getRepresentation() + ", " + b.getRepresentation() + ")) ? " + aTrue.getRepresentation() + " : " + aFalse.getRepresentation() + ";");
}
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.field.ShaderFieldType in project gdx-graph by MarcinSc.
the class FractionalPartShaderNodeBuilder 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("// Fractional part node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = fract(" + inputValue.getRepresentation() + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.field.ShaderFieldType in project gdx-graph by MarcinSc.
the class MaximumShaderNodeBuilder 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 aValue = inputs.get("a");
FieldOutput bValue = inputs.get("b");
ShaderFieldType resultType = aValue.getFieldType();
commonShaderBuilder.addMainLine("// Maximum node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = max(" + aValue.getRepresentation() + ", " + bValue.getRepresentation() + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.field.ShaderFieldType in project gdx-graph by MarcinSc.
the class ModuloShaderNodeBuilder 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 aValue = inputs.get("a");
FieldOutput bValue = inputs.get("b");
ShaderFieldType resultType = aValue.getFieldType();
commonShaderBuilder.addMainLine("// Modulo node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = mod(" + aValue.getRepresentation() + ", " + bValue.getRepresentation() + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
Aggregations