Code:
@Override
public void simpleInitApp() {
Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
rootNode.attachChild(sky);
EnvironmentCamera envCam = new EnvironmentCamera();
envCam.initialize(getStateManager(), this);
getStateManager().attach(envCam);
LightProbe lightProbe = LightProbeFactory.makeProbe(envCam, rootNode, new JobProgressAdapter<LightProbe>() {
long time;
@Override
public void start() {
time = System.currentTimeMillis();
}
@Override
public void done(LightProbe result) {
long end = System.currentTimeMillis();
Logger.getLogger(getClass().getName()).log(Level.INFO, "Generation done in {0}", ((float) (end - time) / 1000f));
}
});
rootNode.addLight(lightProbe);
Material unshaded = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
unshaded.setColor("GlowColor", ColorRGBA.White);
Geometry shinyBox = new Geometry("Shiny", new Box(1, 1, 1));
shinyBox.setLocalTranslation(0, 0, -1f);
shinyBox.setMaterial(unshaded);
rootNode.attachChild(shinyBox);
Material pbr = new Material(assetManager, "Common/MatDefs/Light/PBRLighting.j3md");
pbr.setColor("BaseColor", ColorRGBA.White);
pbr.setFloat("Roughness", 0.5f);
pbr.setFloat("Metallic", 0.5f);
Geometry pbrBox = new Geometry("PBR", new Box(0.5f, 0.5f, 0.5f));
pbrBox.setMaterial(pbr);
pbrBox.setLocalTranslation(-1f, 0, 0.5f);
rootNode.attachChild(pbrBox);
Material normalLighting = assetManager.loadAsset(new MaterialKey("Common/Materials/RedColor.j3m"));
Geometry normalBox = new Geometry("normal", new Box(0.5f, 0.5f, 0.5f));
normalBox.setMaterial(normalLighting);
normalBox.setLocalTranslation(1f, 0, 0.5f);
rootNode.attachChild(normalBox);
BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
FilterPostProcessor bloomFilter = null;
for (SceneProcessor filter : viewPort.getProcessors()) {
if (filter instanceof FilterPostProcessor) {
bloomFilter = (FilterPostProcessor) filter;
break;
}
}
if (bloomFilter != null) {
bloomFilter.addFilter(bloom);
} else {
FilterPostProcessor newFPP = new FilterPostProcessor(assetManager);
newFPP.addFilter(bloom);
viewPort.addProcessor(newFPP);
}
}
As you can see, the bloom effect appears in front of the box with the pbr material (left) even though the pbr geometry is placed in front of the bloom geometry.
Any ideas as to why this is?
Thanks!