All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gempukku.libgdx.graph.plugin.particles.particle.ParticleUVShaderNodeBuilder Maven / Gradle / Ivy

The newest version!
package com.gempukku.libgdx.graph.plugin.particles.particle;

import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectSet;
import com.gempukku.libgdx.graph.plugin.particles.config.ParticleUVShaderNodeConfiguration;
import com.gempukku.libgdx.graph.shader.GraphShader;
import com.gempukku.libgdx.graph.shader.GraphShaderContext;
import com.gempukku.libgdx.graph.shader.ShaderFieldType;
import com.gempukku.libgdx.graph.shader.builder.FragmentShaderBuilder;
import com.gempukku.libgdx.graph.shader.builder.VertexShaderBuilder;
import com.gempukku.libgdx.graph.shader.node.ConfigurationShaderNodeBuilder;
import com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput;
import com.gempukku.libgdx.graph.util.LibGDXCollections;

public class ParticleUVShaderNodeBuilder extends ConfigurationShaderNodeBuilder {
    public ParticleUVShaderNodeBuilder() {
        super(new ParticleUVShaderNodeConfiguration());
    }

    @Override
    public ObjectMap buildVertexNodeSingleInputs(boolean designTime, String nodeId, JsonValue data, ObjectMap inputs, ObjectSet producedOutputs, VertexShaderBuilder vertexShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
        vertexShaderBuilder.addAttributeVariable(VertexAttribute.TexCoords(0), ShaderProgram.TEXCOORD_ATTRIBUTE + 0, "vec3");

        return LibGDXCollections.singletonMap("uv", new DefaultFieldOutput(ShaderFieldType.Vector2, "a_texCoord0"));
    }

    @Override
    public ObjectMap buildFragmentNodeSingleInputs(boolean designTime, String nodeId, JsonValue data, ObjectMap inputs, ObjectSet producedOutputs, VertexShaderBuilder vertexShaderBuilder, FragmentShaderBuilder fragmentShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
        vertexShaderBuilder.addAttributeVariable(VertexAttribute.TexCoords(0), ShaderProgram.TEXCOORD_ATTRIBUTE + 0, "vec2");
        if (!vertexShaderBuilder.hasVaryingVariable("v_uv")) {
            vertexShaderBuilder.addMainLine("// Particle UV Node");
            vertexShaderBuilder.addVaryingVariable("v_uv", "vec2");
            vertexShaderBuilder.addMainLine("v_uv = a_texCoord0;");

            fragmentShaderBuilder.addVaryingVariable("v_uv", "vec2");
        }
        return LibGDXCollections.singletonMap("uv", new DefaultFieldOutput(ShaderFieldType.Vector2, "v_uv"));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy