Trouble with Fade

Hi all.



I’m quite new with JME, even if I have read a lot of topics/tutorials.



I’ve run into a weird bug using the Fade Post-processing filter.



FadeIn(), then FadeOut() works perfectly.

FadeOut(), then FadeIn() does not work. It fades out properly, then turns clear at once. (It does not stay black). No fadeIn next. But this is repeatable; if I FadeOut() again, it works again, but still not the next FadeIn(). I’ve tried printing the getValue(), and it does change with frames.



Even stranger, if I have FadeIn() before FadeOut() is complete, it works !



I have noted the tutorial about the fading kinematic events does not use the “automatic” feature of the filter. Instead, it makes the value changing manually with setValue(). Is this for working around a known bug?



Thanks,

Laurent.

Ok, here is a test case with some partial workaround.



[java]package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.font.BitmapText;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.post.FilterPostProcessor;

import com.jme3.post.filters.FadeFilter;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;



public class Main extends SimpleApplication {



public static void main(String[] args) {

Main app = new Main();

app.start();

}

private FadeFilter fade;

private boolean in;

private BitmapText hud;



@Override

public void simpleInitApp() {

Box b = new Box(Vector3f.ZERO, 1, 1, 1);

Geometry geom = new Geometry(“Box”, b);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Blue);

geom.setMaterial(mat);

rootNode.attachChild(geom);



guiFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

hud = new BitmapText(guiFont, false);

hud.setText(“Hello World”);

hud.setLocalTranslation(cam.getWidth()-300, hud.getLineHeight(), 1);

guiNode.attachChild(hud);



FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

fade = new FadeFilter(3);

fpp.addFilter(fade);

viewPort.addProcessor(fpp);



fade.fadeOut();

in = false;

}



@Override

public void simpleUpdate(float tpf) {

if (!fade.isEnabled()) {

if (in) {

fade.fadeOut();

in = false;

} else {

fade.fadeIn();

in = true;

}

update(); // Workaround

fade.setEnabled(true); // Workaround

} else {

hud.setText(“fade Value=”+fade.getValue());

/* if (in && fade.getValue()>0.999) {

fade.fadeOut();

in = false;

} else

if (!in && fade.getValue()<0.001) {

fade.fadeIn();

in = true;

} */

} // if fade enabled

} // simpleUpdate(tpf)

} // class Main

[/java]



The commented-out part is for the partial effect, reversing before the filter deactivates.



The workaround consists in calling Application.update() before fade.setEnable(true). If any of these is removed, it does not work anymore : the filter’s display is blocked as if value was set to 1, which is not.



With this, it works but with a slight ugly flash when the filter deactivates at value 0 (all black) before reactivating.



Any idea on the why and how ?



Laurent.

2 Likes

I’ll look into this

it should be fixed in last SVN

3 Likes

Thanks, it is solved. It works perfectly with the nightly update.

I still have trouble with several viewports and associated cameras , but I have to check with the old version to see if that’s a regression or not.
Similarly, it seems that screen capture does not work anymore when Fade is registered (even if not active). I will try and make a test case for it.

2 Likes