Search in sources :

Example 1 with SampleTextureNode

use of com.talosvfx.talos.editor.addons.shader.nodes.SampleTextureNode in project talos by rockbite.

the class ShaderNodeStage method exportPixmap.

public Pixmap exportPixmap() {
    if (colorOutput == null)
        return null;
    frameBuffer.begin();
    spriteBatch.begin();
    Vector2 tmp = new Vector2();
    Vector2 targetSize = new Vector2(64, 64);
    for (NodeWidget nodeWidget : nodeBoard.nodes) {
        if (nodeWidget instanceof SampleTextureNode) {
            SampleTextureNode node = (SampleTextureNode) nodeWidget;
            Texture texture = node.getValue();
            if (texture.getWidth() > targetSize.x) {
                targetSize.x = texture.getWidth();
            }
            if (texture.getHeight() > targetSize.y) {
                targetSize.y = texture.getHeight();
            }
        }
    }
    viewport.update((int) targetSize.x, (int) targetSize.y);
    spriteBatch.setProjectionMatrix(viewport.getCamera().combined);
    tmp.set(colorOutput.getShaderBox().getX(), colorOutput.getShaderBox().getY());
    colorOutput.getShaderBox().setPosition(0, 0);
    colorOutput.getShaderBox().draw(spriteBatch, 1f);
    colorOutput.getShaderBox().setPosition(tmp.x, tmp.y);
    spriteBatch.end();
    Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, (int) targetSize.x, (int) targetSize.y);
    frameBuffer.end();
    return pixmap;
}
Also used : SampleTextureNode(com.talosvfx.talos.editor.addons.shader.nodes.SampleTextureNode) Vector2(com.badlogic.gdx.math.Vector2) NodeWidget(com.talosvfx.talos.editor.nodes.NodeWidget)

Aggregations

Vector2 (com.badlogic.gdx.math.Vector2)1 SampleTextureNode (com.talosvfx.talos.editor.addons.shader.nodes.SampleTextureNode)1 NodeWidget (com.talosvfx.talos.editor.nodes.NodeWidget)1