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;
}
Aggregations