use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class ExponentialBase2ShaderNodeBuilder 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("// Exponential base 2 node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = exp2(" + inputValue.getRepresentation() + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class RadiansShaderNodeBuilder 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("// Radians node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = radians(" + 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 TanShaderNodeBuilder 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("// Tangent node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = tan(" + 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 MergeShaderNodeBuilder 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 xValue = inputs.get("x");
FieldOutput yValue = inputs.get("y");
FieldOutput zValue = inputs.get("z");
FieldOutput wValue = inputs.get("w");
String x = xValue != null ? xValue.getRepresentation() : "0.0";
String y = yValue != null ? yValue.getRepresentation() : "0.0";
String z = zValue != null ? zValue.getRepresentation() : "0.0";
String w = wValue != null ? wValue.getRepresentation() : "0.0";
commonShaderBuilder.addMainLine("// Merge Node");
ObjectMap<String, DefaultFieldOutput> result = new ObjectMap<>();
if (producedOutputs.contains("v2")) {
String name = "v2_" + nodeId;
commonShaderBuilder.addMainLine("vec2 " + name + " = vec2(" + x + ", " + y + ");");
result.put("v2", new DefaultFieldOutput(ShaderFieldType.Vector2, name));
}
if (producedOutputs.contains("v3")) {
String name = "v3_" + nodeId;
commonShaderBuilder.addMainLine("vec3 " + name + " = vec3(" + x + ", " + y + ", " + z + ");");
result.put("v3", new DefaultFieldOutput(ShaderFieldType.Vector3, name));
}
if (producedOutputs.contains("color")) {
String name = "color_" + nodeId;
commonShaderBuilder.addMainLine("vec4 " + name + " = vec4(" + x + ", " + y + ", " + z + ", " + w + ");");
result.put("color", new DefaultFieldOutput(ShaderFieldType.Vector4, name));
}
return result;
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class RemapValueShaderNodeBuilder 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");
Array<Vector2> pointArray = new Array<>();
JsonValue points = data.get("points");
for (String point : points.asStringArray()) {
String[] split = point.split(",");
pointArray.add(new Vector2(Float.parseFloat(split[0]), Float.parseFloat(split[1])));
}
ClampMethod clampMethod = ClampMethod.valueOf(data.getString("clamp", "Normal"));
String remapValueFunctionName = "remapValue_" + nodeId;
String functionText = createRemapValueFunction(remapValueFunctionName, pointArray, clampMethod);
commonShaderBuilder.addFunction(remapValueFunctionName, functionText);
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine("// Remap Value node");
commonShaderBuilder.addMainLine("float " + name + " = " + remapValueFunctionName + "(" + inputValue + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
Aggregations