Zdof setFocusDistance & fog setFogDistance not working

Hello,



i have tried the examples but there seem to be a problem

both with the distance of the effect probably regarding the zbuffer

setting the distance does not change anything, i even tried at runtime, nothing changes :frowning:



is there something that need to be enabled in the app to have it work ?



here is my code

Code:
public static void EnableDepthOfField() { FilterPostProcessor dofFpp = new FilterPostProcessor(assetManager); // fpp.setNumSamples(4); dofFilter = new DepthOfFieldFilter(); dofFilter.setFocusDistance(focusd); dofFilter.setFocusRange(focusr); dofFilter.setBlurScale(2.4f); dofFpp.addFilter(dofFilter); viewPort.addProcessor(dofFpp); }
public static void EnableFog() {
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    //fpp.setNumSamples(4);
    fogFilter = new FogFilter();
    fogFilter.setFogColor(new ColorRGBA(0.9f, 0.0f, 0.0f, 1.0f));
    fogFilter.setFogDensity(1f);
    fogFilter.setFogDistance(230);
    fpp.addFilter(fogFilter);
    viewPort.addProcessor(fpp);
    }</div>

thanks

Use the same FilterPostProcessor for both filters and add it once to the viewport

there is a setEnabled(boolean) method on Filter so you can create your filter in the init method and then just call the setEnabled.

Also you’d better add the fog before the DOF.



[java]

FilterPostProcessor fpp ;



public void simpleInit(){

fpp = new FilterPostProcessor(assetManager);



fogFilter = new FogFilter();

fogFilter.setFogColor(new ColorRGBA(0.9f, 0.0f, 0.0f, 1.0f));

fogFilter.setFogDensity(1f);

fogFilter.setFogDistance(230);

fpp.addFilter(fogFilter);



dofFilter = new DepthOfFieldFilter();

dofFilter.setFocusDistance(focusd);

dofFilter.setFocusRange(focusr);

dofFilter.setBlurScale(2.4f);

fpp .addFilter(dofFilter);





viewPort.addProcessor(fpp);



}



[/java]

@nehon said:
Use the same FilterPostProcessor for both filters and add it once to the viewport
there is a setEnabled(boolean) method on Filter so you can create your filter in the init method and then just call the setEnabled.
Also you'd better add the fog before the DOF.
...


here is what i do but the zblur jitters like a camera that can't find a correct focus :(
[java]
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
viewPort.addProcessor(fpp);
EnvironementFactory.EnableFog(fpp);
EnvironementFactory.EnableDepthOfField(fpp);

public static void EnableDepthOfField(FilterPostProcessor fpp) {
dofFilter = new DepthOfFieldFilter();
dofFilter.setFocusDistance(focusd);
dofFilter.setFocusRange(focusr);
dofFilter.setBlurScale(2.4f);
fpp.addFilter(dofFilter);
}

public static void EnableFog(FilterPostProcessor fpp) {
fogFilter = new FogFilter();
fogFilter.setFogColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
fogFilter.setFogDensity(1f);
fogFilter.setFogDistance(230);
fpp.addFilter(fogFilter);
}

[/java]

If the focus changes then that sounds like you are some how resetting it every time or something. Where do you call your (miscapitalized) Enable methods and what is focusd and focusr set to?