use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class DotShapeShaderNodeBuilder 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 uvValue = inputs.get("uv");
String uv = uvValue.getRepresentation();
commonShaderBuilder.addMainLine("// Dot shape node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine("float " + name + " = 2.0 * clamp(0.5 - distance(" + uv + ", vec2(0.5)), 0.0, 0.5);");
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 BillboardSpriteShaderNodeBuilder 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, "billboardSprite");
commonShaderBuilder.addUniformVariable("u_cameraUp", "vec3", true, UniformSetters.cameraUp, "Camera up");
commonShaderBuilder.addUniformVariable("u_cameraDirection", "vec3", true, UniformSetters.cameraDirection, "Camera direction");
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 + " = billboardSprite(" + 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 PerlinNoise3DShaderNodeBuilder 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 progressValue = inputs.get("progress");
FieldOutput scaleValue = inputs.get("scale");
FieldOutput rangeValue = inputs.get("range");
String scale = scaleValue != null ? scaleValue.getRepresentation() : "1.0";
String name = "result_" + nodeId;
String output;
commonShaderBuilder.addMainLine("// Perlin noise 3D node");
if (progressValue != null) {
loadFragmentIfNotDefined(commonShaderBuilder, "noise/common");
loadFragmentIfNotDefined(commonShaderBuilder, "noise/perlinNoise4d");
output = "perlinNoise4d(vec4(" + pointValue.getRepresentation() + " * " + scale + ", " + progressValue.getRepresentation() + "))";
} else {
loadFragmentIfNotDefined(commonShaderBuilder, "noise/common");
loadFragmentIfNotDefined(commonShaderBuilder, "noise/perlinNoise3d");
output = "perlinNoise3d(" + pointValue.getRepresentation() + " * " + scale + ")";
}
String noiseRange = "vec2(-1.0, 1.0)";
if (rangeValue != null) {
String functionName = RemapShaderNodeBuilder.appendRemapFunction(commonShaderBuilder, ShaderFieldTypeRegistry.findShaderFieldType(ShaderFieldType.Float));
commonShaderBuilder.addMainLine("float " + name + " = " + functionName + "(" + output + ", " + noiseRange + ", " + rangeValue.getRepresentation() + ");");
} else {
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 SimplexNoise3DShaderNodeBuilder 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 progressValue = inputs.get("progress");
FieldOutput scaleValue = inputs.get("scale");
FieldOutput rangeValue = inputs.get("range");
String scale = scaleValue != null ? scaleValue.getRepresentation() : "1.0";
String name = "result_" + nodeId;
String output;
commonShaderBuilder.addMainLine("// Simplex noise 3D node");
if (progressValue != null) {
loadFragmentIfNotDefined(commonShaderBuilder, "noise/common");
loadFragmentIfNotDefined(commonShaderBuilder, "noise/simplexNoise4d");
output = "simplexNoise4d(vec4(" + pointValue.getRepresentation() + " * " + scale + ", " + progressValue.getRepresentation() + "))";
} else {
loadFragmentIfNotDefined(commonShaderBuilder, "noise/common");
loadFragmentIfNotDefined(commonShaderBuilder, "noise/simplexNoise3d");
output = "simplexNoise3d(" + pointValue.getRepresentation() + " * " + scale + ")";
}
String noiseRange = "vec2(-1.0, 1.0)";
if (rangeValue != null) {
String functionName = RemapShaderNodeBuilder.appendRemapFunction(commonShaderBuilder, ShaderFieldTypeRegistry.findShaderFieldType(ShaderFieldType.Float));
commonShaderBuilder.addMainLine("float " + name + " = " + functionName + "(" + output + ", " + noiseRange + ", " + rangeValue.getRepresentation() + ");");
} else {
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 VoronoiDistance3DShaderNodeBuilder 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");
FieldOutput rangeValue = inputs.get("range");
String scale = (scaleValue != null) ? scaleValue.getRepresentation() : "1.0";
String progress = (progressValue != null) ? progressValue.getRepresentation() : "0.0";
loadFragmentIfNotDefined(commonShaderBuilder, "voronoiDistance3d");
commonShaderBuilder.addMainLine("// Voronoi distance 3D node");
String name = "result_" + nodeId;
String output = "voronoiDistance3d(" + pointValue.getRepresentation() + " * " + scale + ", " + progress + ")";
String noiseRange = "vec3(0.0, 2.6)";
if (rangeValue != null) {
String functionName = RemapShaderNodeBuilder.appendRemapFunction(commonShaderBuilder, ShaderFieldTypeRegistry.findShaderFieldType(ShaderFieldType.Float));
commonShaderBuilder.addMainLine("float " + name + " = " + functionName + "(" + output + ", " + noiseRange + ", " + rangeValue.getRepresentation() + ");");
} else {
commonShaderBuilder.addMainLine("float " + name + " = " + output + ";");
}
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
Aggregations