Search in sources :

Example 26 with DefaultFieldOutput

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

Example 27 with DefaultFieldOutput

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

Example 28 with DefaultFieldOutput

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

Example 29 with DefaultFieldOutput

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

Example 30 with DefaultFieldOutput

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