use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class PowerShaderNodeBuilder 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("// Power node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = pow(" + aValue.getRepresentation() + ", " + bValue.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 DotProductShaderNodeBuilder 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");
String resultType = ShaderFieldType.Float;
commonShaderBuilder.addMainLine("// Dot product node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine("float " + name + " = dot(" + aValue.getRepresentation() + ", " + bValue.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 ScreenSpriteShaderNodeBuilder 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 positionField = inputs.get("position");
FieldOutput uvField = inputs.get("uv");
FieldOutput anchorField = inputs.get("anchor");
FieldOutput sizeField = inputs.get("size");
FieldOutput rotationField = inputs.get("rotation");
loadFragmentIfNotDefined(commonShaderBuilder, "screenSprite");
String position = positionField.getRepresentation();
String uv = uvField.getRepresentation();
String size = resolveSize(sizeField);
String anchor = resolveAnchor(anchorField);
String rotation = (rotationField != null) ? rotationField.getRepresentation() : "0.0";
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine("vec3 " + name + " = screenSprite(" + position + ", " + uv + ", " + size + ", " + anchor + ", " + rotation + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Vector3, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class VoronoiBorder3DShaderNodeBuilder 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 pointValue = inputs.get("point");
FieldOutput scaleValue = inputs.get("scale");
FieldOutput progressValue = inputs.get("progress");
String scale = (scaleValue != null) ? scaleValue.getRepresentation() : "1.0";
String progress = (progressValue != null) ? progressValue.getRepresentation() : "0.0";
loadFragmentIfNotDefined(commonShaderBuilder, "voronoiBorder3d");
commonShaderBuilder.addMainLine("// Voronoi border 3D node");
String name = "result_" + nodeId;
String output = "voronoiBorder3d(" + pointValue.getRepresentation() + " * " + scale + ", " + progress + ")";
commonShaderBuilder.addMainLine("float " + name + " = " + output + ";");
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 PixelSizeShaderNodeBuilder 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) {
commonShaderBuilder.addUniformVariable("u_pixelSize", "vec2", true, UniformSetters.pixelSize, "Pixel size");
ObjectMap<String, DefaultFieldOutput> result = new ObjectMap<>();
if (producedOutputs.contains("size")) {
result.put("size", new DefaultFieldOutput(ShaderFieldType.Vector2, "u_pixelSize"));
}
if (producedOutputs.contains("x")) {
result.put("x", new DefaultFieldOutput(ShaderFieldType.Vector2, "u_pixelSize.x"));
}
if (producedOutputs.contains("y")) {
result.put("y", new DefaultFieldOutput(ShaderFieldType.Vector2, "u_pixelSize.y"));
}
return result;
}
Aggregations