Depth problems with fade filter [SOLVED]

I added the fade filter like described here https://wiki.jmonkeyengine.org/doku.php/jme3:advanced:fade?s[]=fade&s[]=out
but somehow everything looks messed and stuff which should be behind is visible. Btw just adding the filter is enough to have the problem. Fadeing itself works. Is that a known issue? Any ideas or things I could try to solve it?
If that is not a wellknown and kind of a error reproduction sample is really needed I will try to do that of course.

Many thanks
Christian

make sure the filter is the last one in the filter list

It is the only one :slight_smile: And how could I influence it? Are there code snipplets?

the order is the order you add the filter to the processor… but yeah if it’s the only one, might not be the issue :stuck_out_tongue:

A test case could really help there. Tbh the fade filter is not used that much and was done rather quickly.

Silly me… when I want to fade the screen I just put a big quad in front of everything. :slight_smile:

@pspeed: yeah I also found your solution in older posts, but I thought if there is something which already do what I want why do the same my self :wink: Programmers tend to reinvent the wheel quite often.
@nehon: ok I try to make a simple test case. I’ll come back to you if I have something.

well… actually that’s what the filter does in the end :stuck_out_tongue:
But yeah in a more convoluted way

I don’t know if you use Lemur already but I think it’s pretty trivial now to create a full screen Panel and then add fade in and fade out effects to it using the new effects stuff.

@pspeed Of cours I use Lemur :slight_smile:
So you guys tell me dont use that fade filter which do something simple complicated.
Is there a sample for fading with Lemur? Some tests or opensource project I could look at?
@nehon: Still interessted in a reproduction sample?

Well I think we should just deprecate this filter anyway, to the profit of a more straight forward implementation. So if youa re going to make it differently, don’t bother to make a test case.

ok. if you depreciate it I will not make a test case for this and try it with Lemur (but no clue how so far)

create a panel, make it full screen, then add a black background component, then play with the alpha of the color.

Lemur already has a setAlpha() that works for all regular GUI elements.

…but you can also animate it.

Not a direct sample but you can get started reading here if you want to know more:

There is a built in Tween for fading GUI elements… create the tween like:

Tween fade = PanelTweens.fade(target, 0f, 1f, length);

I always intended to add some standard effects but I haven’t gotten around to it… and they are not hard to make when needed: For a one-off effect set:

final float length = 3; // 3 seconds

Effect<Panel> fadeIn = new AbstractEffect<>("fade") {
    public Animation create( Panel target, EffectInfo existing ) {
        Tween fade = PanelTweens.fade(target, 0f, 1f, length);
        return new TweenAnimation(fade);
    }
}

Effect<Panel> fadeOut = new AbstractEffect<>("fade") {
    public Animation create( Panel target, EffectInfo existing ) {
        Tween fade = PanelTweens.fade(target, 1f, 0f, length);
        return new TweenAnimation(fade);
    }
}

// Now that we've created the effects we can set them to our Panel.
myPanel.addEffect("fadeIn", fadeIn);
myPanel.addEffect("fadeOut", fadeOut);

…something like that. Then you can run it with panel.runEffect(“fadeIn”) or whatever.

And note: sometimes it’s nicer to give tweens a little smoothing like:
return new TweenAnimation(Tweens.smoothStep(fade));
…then they fade in/out with a smooth_step style hermite curve.

Note: you can also bypass the effects support and just run an animation directly:

AnimationState anim = getState(AnimationState.class);
anim.add(PanelTweens.fade(myPanel, 1f, 0f, length));

I guess I could have started with that one as it’s the easiest. :slight_smile:

The effects based one is slightly nicer because it’s easily repeatable, can be defined in styles, and the fade in and fade out effects will automatically cancel each other as I have it configured above.

1 Like

Looks ver cool and exactly what I need.
I tried it but somehow it does not find Effect nor Animation (except some stuff in swing or so). Any ideas? Maybe my Lemur is too old? Which version do I need?

A newer one than you have, I guess.

Just run the latest one, either 1.7.1 or 1.8.1 depending on which version of JME that you use.

Ok the simple one seems to work. More or less :slight_smile: because now I have now a blue fog like thing over my scene after fade in. Maybe I have to remove the glass style I guess?

ok yes it was the glass style. If set no style at all that blue fog is gone :slight_smile:

Thanks a lot for your help, that works as expected :slight_smile:

You’re welcome!