So i have something very strange going on with the filter post processor. I’m trying to make my own filter, but no matter what i do i always get a black screen. So i decided to copy and paste all of the files for the Color Overlay filter, and i still get a black screen. Then in the filter Java file i made, I referenced directly to the Overlay.j3md that’s built in, and it works. Then i reference to my own j3md, which is 100% IDENTICAL to Overlay.j3md, and i get a black screen. So i know my shaders aren’t the problem, it’s that JME doesn’t like me using my own material file. Or maybe i broke it. But anyway, here is my code:
package Filters;
import com.jme3.asset.AssetManager;
import com.jme3.export.InputCapsule;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import java.io.IOException;
/**
* This filter simply multiply the whole scene by a color
* @author Rémy Bouquet aka Nehon
*/
public class EnhancedLighting extends Filter {
private ColorRGBA color = ColorRGBA.White;
/**
* creates a colorOverlayFilter with a white coor (transparent)
*/
public EnhancedLighting() {
super("Color Overlay");
}
/**
* creates a colorOverlayFilter with the given color
* @param color
*/
public EnhancedLighting(ColorRGBA color) {
this();
this.color = color;
}
@Override
protected Material getMaterial() {
material.setColor("Color", color);
return material;
}
/**
* returns the color
* @return color
*/
public ColorRGBA getColor() {
return color;
}
/**
* sets the color
* @param color
*/
public void setColor(ColorRGBA color) {
this.color = color;
}
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "MatDefs/EnhancedLighting/EnhancedLighting.j3md"); //this breaks everything
}
@Override
public void write(JmeExporter ex) throws IOException {
super.write(ex);
OutputCapsule oc = ex.getCapsule(this);
oc.write(color, "color", ColorRGBA.White);
}
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
color = (ColorRGBA) ic.readSavable("color", ColorRGBA.White);
}
}
And here’s my j3md file:
MaterialDef Default GUI {
MaterialParameters {
Int NumSamples
Int NumSamplesDepth
Texture2D Texture
Color Color
}
Technique {
VertexShader GLSL150: Common/MatDefs/Post/Post15.vert
FragmentShader GLSL150: Common/MatDefs/Post/Overlay15.frag
WorldParameters {
}
Defines {
RESOLVE_MS : NumSamples
}
}
Technique {
VertexShader GLSL100: Common/MatDefs/Post/Post.vert
FragmentShader GLSL100: Common/MatDefs/Post/Overlay.frag
WorldParameters {
}
}
}
As you can see, it’s identical to Overlay.j3md, but it doesn’t work. When I change the line material = new Material(manager, "MatDefs/EnhancedLighting/EnhancedLighting.j3md");
to material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md");
it works, which is strange since there is literally no difference between the two files. So can anyone tell me why this is happening?