use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class ParticleLifePercentageShaderNodeBuilder method buildVertexNodeSingleInputs.
@Override
public ObjectMap<String, ? extends FieldOutput> buildVertexNodeSingleInputs(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, FieldOutput> inputs, ObjectSet<String> producedOutputs, VertexShaderBuilder vertexShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
vertexShaderBuilder.addAttributeVariable("a_birthTime", 1, "float", "Particle birth-time");
vertexShaderBuilder.addAttributeVariable("a_deathTime", 1, "float", "Particle death-time");
vertexShaderBuilder.addUniformVariable("u_time", "float", true, UniformSetters.time, "Time");
String name = "result_" + nodeId;
vertexShaderBuilder.addMainLine("// Particle Lifetime Percentage Node");
vertexShaderBuilder.addMainLine("float" + " " + name + " = (u_time - a_birthTime) / (a_deathTime - a_birthTime);");
return LibGDXCollections.singletonMap("percentage", new DefaultFieldOutput(ShaderFieldType.Float, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class ParticleLifePercentageShaderNodeBuilder method buildFragmentNodeSingleInputs.
@Override
public ObjectMap<String, ? extends FieldOutput> buildFragmentNodeSingleInputs(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, FieldOutput> inputs, ObjectSet<String> producedOutputs, VertexShaderBuilder vertexShaderBuilder, FragmentShaderBuilder fragmentShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
vertexShaderBuilder.addAttributeVariable("a_birthTime", 1, "float", "Particle birth-time");
vertexShaderBuilder.addAttributeVariable("a_deathTime", 1, "float", "Particle death-time");
vertexShaderBuilder.addUniformVariable("u_time", "float", true, UniformSetters.time, "Time");
if (!vertexShaderBuilder.hasVaryingVariable("v_lifePercentage")) {
vertexShaderBuilder.addMainLine("// Particle Lifetime Percentage Node");
vertexShaderBuilder.addVaryingVariable("v_lifePercentage", "float");
vertexShaderBuilder.addMainLine("v_lifePercentage = (u_time - a_birthTime) / (a_deathTime - a_birthTime);");
fragmentShaderBuilder.addVaryingVariable("v_lifePercentage", "float");
}
return LibGDXCollections.singletonMap("percentage", new DefaultFieldOutput(ShaderFieldType.Float, "v_lifePercentage"));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class ParticlePositionShaderNodeBuilder method buildFragmentNodeSingleInputs.
@Override
public ObjectMap<String, ? extends FieldOutput> buildFragmentNodeSingleInputs(boolean designTime, String nodeId, JsonValue data, ObjectMap<String, FieldOutput> inputs, ObjectSet<String> producedOutputs, VertexShaderBuilder vertexShaderBuilder, FragmentShaderBuilder fragmentShaderBuilder, GraphShaderContext graphShaderContext, GraphShader graphShader) {
VertexAttribute attribute = VertexAttribute.Position();
copyAttributeToFragmentShader(attribute, "v_position", "Particle position", vertexShaderBuilder, fragmentShaderBuilder);
return LibGDXCollections.singletonMap("position", new DefaultFieldOutput(ShaderFieldType.Vector3, "v_position"));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class ReciprocalShaderNodeBuilder 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("// Reciprocal node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = 1.0 / " + inputValue.getRepresentation() + ";");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
use of com.gempukku.libgdx.graph.shader.node.DefaultFieldOutput in project gdx-graph by MarcinSc.
the class FloorShaderNodeBuilder 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("// Floor node");
String name = "result_" + nodeId;
commonShaderBuilder.addMainLine(resultType.getShaderType() + " " + name + " = floor(" + inputValue.getRepresentation() + ");");
return LibGDXCollections.singletonMap("output", new DefaultFieldOutput(resultType, name));
}
Aggregations