I haven’t been able to find much documentation on filters at all I can’t seem to figure out how this should work.
What I’ve pieced together from the BloomFilter which doesn’t seem to render anything when run:
@Override
protected void initFilter(AssetManager assetManager, RenderManager rm, ViewPort vp, final int w, final int h) {
screenWidth = (int) Math.max(1, (w / downSamplingFactor));
screenHeight = (int) Math.max(1, (h / downSamplingFactor));
Material blank = new Material(assetManager, "assets/filters/lensflare/Blank.j3md");
//I think I may need to make a new pass that renders at a lower res?
downscalepass = new Pass();
downscalepass.setPassMaterial(blank);
downscalepass.init(rm.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth);
//and then render it again?
material = new Material(assetManager, "assets/filters/lensflare/Blank.j3md");
Pass main = new Pass(){
@Override
public void beforeRender() {
material.setTexture("Texture", downscalepass.getRenderedTexture());
}
};
main.setPassMaterial(material);
main.init(rm.getRenderer(), w, h, Format.RGBA8, Format.Depth);
}
Blank.frag is pretty blank for testing:
#import "Common/ShaderLib/MultiSample.glsllib"
uniform sampler2D m_Texture;
in vec2 texCoord;
out vec4 fragColor;
void main() {
fragColor = texture2D(m_Texture, texCoord);
}
The wiki only explains how to add filters to the game and not how they’re actually supposed to be set up when making custom ones so I’m kind of at a loss here.
You have to add the pass to a collection called postPasses or something like that (can’t look at the code right now).
Look for a collection like that in Filter.java
You’re right, I somehow missed that (postRenderPasses). Thanks!
It didn’t start to work right away, since I forgot a few other things but starting from the BloomFilter and removing all blur related stuff seems to have solved it.