Search in sources :

Example 41 with DefaultFieldOutput

use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.

the class CheckerboardShapeShaderNodeBuilder 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");
    FieldOutput repeatValue = inputs.get("repeat");
    String uv = uvValue.getRepresentation();
    String repeat = repeatValue != null ? repeatValue.getRepresentation() : "vec2(1.0)";
    commonShaderBuilder.addMainLine("// Checkerboard shape node");
    String name = "result_" + nodeId;
    commonShaderBuilder.addMainLine("float " + name + " = mod(dot(vec2(1.0), step(vec2(0.5), fract(" + uv + " * " + repeat + "))), 2.0);");
    return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
Also used : DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput)

Example 42 with DefaultFieldOutput

use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.

the class EllipseShapeShaderNodeBuilder 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");
    FieldOutput sizeValue = inputs.get("size");
    FieldOutput borderValue = inputs.get("border");
    if (sizeValue != null && sizeValue.getFieldType().getName().equals(ShaderFieldType.Float))
        sizeValue = new DefaultFieldOutput(ShaderFieldType.Vector2, "vec2(" + sizeValue.getRepresentation() + ")");
    String uv = uvValue.getRepresentation();
    String size = sizeValue != null ? sizeValue.getRepresentation() : "vec2(1.0)";
    String border = borderValue != null ? borderValue.getRepresentation() : "0.0";
    commonShaderBuilder.addMainLine("// Ellipse shape node");
    String temp1 = "temp_" + nodeId;
    String name = "result_" + nodeId;
    commonShaderBuilder.addMainLine("vec2 " + temp1 + " = " + uv + " * 2.0 - 1.0;");
    commonShaderBuilder.addMainLine("float " + name + " = 1.0 - smoothstep(0.0 - " + border + ", 0.0, length(" + temp1 + " / " + size + ") - 1.0);");
    return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
Also used : DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput)

Example 43 with DefaultFieldOutput

use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.

the class StepShaderNodeBuilder 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");
    FieldOutput edgeValue = inputs.get("edge");
    if (edgeValue == null)
        edgeValue = new DefaultFieldOutput(ShaderFieldType.Float, "1.0");
    ShaderFieldType resultType = inputValue.getFieldType();
    commonShaderBuilder.addMainLine("// Step node");
    String name = "result_" + nodeId;
    commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = step(" + edgeValue.getRepresentation() + ", " + inputValue.getRepresentation() + ");");
    return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
Also used : DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput) ShaderFieldType(com.gempukku.libgdx.graph.shader.field.ShaderFieldType) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput)

Example 44 with DefaultFieldOutput

use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.

the class LogarithmBase2ShaderNodeBuilder 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("// Logarithm base 2 node");
    String name = "result_" + nodeId;
    commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = log2(" + inputValue.getRepresentation() + ");");
    return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
Also used : DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput) ShaderFieldType(com.gempukku.libgdx.graph.shader.field.ShaderFieldType) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput)

Example 45 with DefaultFieldOutput

use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.

the class NaturalLogarithmShaderNodeBuilder 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("// Natural logarithm node");
    String name = "result_" + nodeId;
    commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = log(" + inputValue.getRepresentation() + ");");
    return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
Also used : DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput) ShaderFieldType(com.gempukku.libgdx.graph.shader.field.ShaderFieldType) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput)

Aggregations

DefaultFieldOutput (com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput)106 ShaderFieldType (com.gempukku.libgdx.graph.shader.field.ShaderFieldType)43 ObjectMap (com.badlogic.gdx.utils.ObjectMap)17 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)7 Texture (com.badlogic.gdx.graphics.Texture)6 TextureDescriptor (com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor)6 Array (com.badlogic.gdx.utils.Array)6 LightColor (com.gempukku.libgdx.graph.plugin.lighting3d.LightColor)5 Lighting3DEnvironment (com.gempukku.libgdx.graph.plugin.lighting3d.Lighting3DEnvironment)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 Lighting3DPrivateData (com.gempukku.libgdx.graph.plugin.lighting3d.Lighting3DPrivateData)4 Lights3DProvider (com.gempukku.libgdx.graph.plugin.lighting3d.provider.Lights3DProvider)4 BasicShader (com.gempukku.libgdx.graph.shader.BasicShader)4 ShaderContext (com.gempukku.libgdx.graph.shader.ShaderContext)4 UniformRegistry (com.gempukku.libgdx.graph.shader.UniformRegistry)4 JsonValue (com.badlogic.gdx.utils.JsonValue)2 BoneTransformFieldType (com.gempukku.libgdx.graph.plugin.boneanimation.property.BoneTransformFieldType)2 ClampMethod (com.gempukku.libgdx.graph.shader.ClampMethod)2 Color (com.badlogic.gdx.graphics.Color)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1