Hi nehon,
I hacked the BloomFilter and got the basic pipeline working - but the results look wrong. Here’s a comparison of results,
Here’s the original shader,
Like I said this is the basic process,
- Pass One - generate data from a shader and store to a 16 bit texture buffer (buffer A).
- Make sure this texture is accessible from same shader.
- Final render pass - simply display results with any color changes.
I’m suspecting that my buffer isn’t in the right format - or isn’t being properly read / written. As far as I know shadertoy uses 16 bit signed buffers. I used RGBA16F for mine. I’m hoping that is correct.
Below is my code for the Filter I’m using.
public class PurpleFilter extends Filter {
private float downSamplingFactor = 1;
private Pass bufApass = new Pass();
private Pass finalPass = new Pass();
private Material bufAmat;
private Material finalMat;
private int screenWidth;
private int screenHeight;
private RenderManager renderManager;
private ViewPort viewPort;
private AssetManager assetManager;
private int initalWidth;
private int initalHeight;
float mytime =0;
public PurpleFilter() {
super("PurpleFilter");
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
this.viewPort = vp;
this.assetManager = manager;
this.initalWidth = w;
this.initalHeight = h;
screenWidth = (int) Math.max(1, (w / downSamplingFactor));
screenHeight = (int) Math.max(1, (h / downSamplingFactor));
// System.out.println(screenWidth + " " + screenHeight);
postRenderPasses = new ArrayList<Pass>();
//buffer A pass
bufAmat = new Material(manager, "MatDefs/PurpleBufA.j3md");
bufApass = new Pass() {
@Override
public void beforeRender() {
bufAmat.setFloat("t", mytime);
mytime+=0.02;
bufAmat.setTexture("Texture", bufApass.getRenderedTexture());
}
};
bufApass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA16F, Format.Depth, 1, bufAmat);
postRenderPasses.add(bufApass);
//final pass
finalMat = new Material(manager, "MatDefs/PurpleFinal.j3md");
finalPass = new Pass() {
@Override
public void beforeRender() {
}
};
finalPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA16F, Format.Depth, 1, finalMat);
postRenderPasses.add(finalPass);
//final material
material = new Material(manager, "MatDefs/PurpleFinal.j3md");
material.setTexture("finalRender", finalPass.getRenderedTexture());
}
@Override
protected Material getMaterial() {
return material;
}
}