use of com.talosvfx.talos.runtime.shaders.ShaderBuilder in project talos by rockbite.
the class ShaderNodeStage method getFragShader.
public String getFragShader() {
ShaderBuilder builder = new ShaderBuilder();
if (colorOutput == null)
return "";
colorOutput.buildFragmentShader(builder);
return builder.getFragmentString();
}
use of com.talosvfx.talos.runtime.shaders.ShaderBuilder in project talos by rockbite.
the class ShaderNodeStage method getShaderData.
public String getShaderData() {
ShaderBuilder builder = new ShaderBuilder();
if (colorOutput == null)
return "";
colorOutput.buildFragmentShader(builder);
String methods = builder.generateMethods();
String main = builder.getMainContent();
StringWriter writer = new StringWriter();
XmlWriter xml = new XmlWriter(writer);
try {
XmlWriter shader = xml.element("shader");
XmlWriter uniforms = shader.element("uniforms");
ObjectMap<String, ShaderBuilder.UniformData> declaredUniforms = builder.getDeclaredUniforms();
for (String uniformName : declaredUniforms.keys()) {
XmlWriter uniform = uniforms.element("uniform");
uniform.attribute("name", uniformName);
uniform.attribute("type", declaredUniforms.get(uniformName).type.getTypeString());
ShaderBuilder.UniformData uniformData = declaredUniforms.get(uniformName);
if (uniformData.type == ShaderBuilder.Type.TEXTURE) {
uniform.text(uniformData.payload.getValueDescriptor());
}
uniform.pop();
}
uniforms.pop();
XmlWriter methodsElem = shader.element("methods");
methodsElem.text("<![CDATA[" + methods + "]]>");
methodsElem.pop();
XmlWriter mainElem = shader.element("main");
mainElem.text("<![CDATA[" + main + "]]>");
mainElem.pop();
shader.pop();
return writer.toString();
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
use of com.talosvfx.talos.runtime.shaders.ShaderBuilder in project talos by rockbite.
the class UIKit method create.
@Override
public void create() {
super.create();
TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("skin/uiskin.atlas"));
skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
skin.addRegions(atlas);
table = new Table();
AbstractShaderNode shaderNode = new AbstractShaderNode() {
@Override
public void prepareDeclarations(ShaderBuilder shaderBuilder) {
}
@Override
public String writeOutputCode(String slotId) {
return null;
}
};
shaderNode.init(skin, null);
XmlReader reader = new XmlReader();
XmlReader.Element root = reader.parse(Gdx.files.internal("addons/shader/nodes.xml"));
shaderNode.constructNode(root.getChild(0).getChild(0));
table.add(shaderNode);
stage = new Stage();
Gdx.input.setInputProcessor(stage);
table.setFillParent(true);
stage.addActor(table);
}
Aggregations