Search in sources :

Example 86 with DefaultFieldOutput

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));
}
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 87 with DefaultFieldOutput

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));
}
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 88 with DefaultFieldOutput

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));
}
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 89 with DefaultFieldOutput

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;
}
Also used : ObjectMap(com.badlogic.gdx.utils.ObjectMap) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput)

Example 90 with DefaultFieldOutput

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));
}
Also used : Array(com.badlogic.gdx.utils.Array) Vector2(com.badlogic.gdx.math.Vector2) ClampMethod(com.gempukku.libgdx.graph.shader.ClampMethod) DefaultFieldOutput(com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput) JsonValue(com.badlogic.gdx.utils.JsonValue) 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