@Override
    protected void preFrame(float tpf) {
        if (playing) {
            value += tpf * direction / duration;

            if (direction > 0 && value > 1) {
                value = 1;
                playing = false;
            }
            if (direction < 0 && value < 0) {
                value = 0;
                playing = false;
            }    
        }
    }
Creates a FadeFilter with the given duration

@param duration the desired duration (in seconds, default=1)
jme3-effects/src/main/java/com/jme3/post/filters/FadeFilter.java