Search in sources :

Example 91 with DefaultFieldOutput

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

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

Example 93 with DefaultFieldOutput

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

Example 94 with DefaultFieldOutput

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

Example 95 with DefaultFieldOutput

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;
}
Also used : ObjectMap(com.badlogic.gdx.utils.ObjectMap) 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