Problems desabling WaterFilter in init

Hello all,

Every time I start my game with water disabled I get

If I leave it enabled I get a good image


This is the code:


import com.jme3.light.DirectionalLight;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;


import com.jme3.renderer.queue.RenderQueue.ShadowMode;

import com.jme3.scene.Node;

import com.jme3.scene.Spatial;

import com.jme3.terrain.geomipmap.TerrainQuad;

import com.jme3.terrain.heightmap.AbstractHeightMap;

import com.jme3.terrain.heightmap.ImageBasedHeightMap;

import com.jme3.texture.Texture;

import com.jme3.texture.Texture.WrapMode;

import com.jme3.util.SkyFactory;

import com.jme3.water.WaterFilter;

public class MyWaterLake extends SimpleApplication{

private WaterFilter water;

public static void main(String[] args) {

MyWaterLake app = new MyWaterLake();



public void simpleInitApp() {



Node scene = initScene();


Vector3f lightDir = new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);

initSun(scene, lightDir);




private void initWaterLake(Vector3f lightDir){

ColorRGBA shallowWaterColor = new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f);

ColorRGBA deepWaterColor = new ColorRGBA(0.0039f, 0.00196f, 0.145f, 1.0f);

Vector3f colorExtinction = new Vector3f(5.0f, 20.0f, 30.0f);

FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

water = new WaterFilter(rootNode, lightDir);


// underwater color



water.setColorExtinction(colorExtinction); // refraction color extintion


// wave stuff






water.setShoreHardness(0.8f); // changed from 0.6 to 0.8 so water integrates better with terrain

water.setRefractionConstant(0.01f); // changed from 0.2 to 0.01 underwater sky woobles more






private void initSun(Spatial scene, Vector3f lightDir){

DirectionalLight sun = new DirectionalLight();





private Node initScene(){

Node mainScene = new Node(“Main Scene”);


return mainScene;


TerrainQuad terrain;

Material matRock;

private void createTerrain(Node rootNode) {

matRock = new Material(assetManager, “Common/MatDefs/Terrain/TerrainLighting.j3md”);

matRock.setBoolean(“useTriPlanarMapping”, false);

matRock.setBoolean(“WardIso”, true);

matRock.setTexture(“AlphaMap”, assetManager.loadTexture(“Textures/Terrain/splat/alphamap.png”));

Texture heightMapImage = assetManager.loadTexture(“Textures/Terrain/splat/mountains512.png”);

Texture grass = assetManager.loadTexture(“Textures/Terrain/splat/grass.jpg”);


matRock.setTexture(“DiffuseMap”, grass);

matRock.setFloat(“DiffuseMap_0_scale”, 64);

Texture dirt = assetManager.loadTexture(“Textures/Terrain/splat/dirt.jpg”);


matRock.setTexture(“DiffuseMap_1”, dirt);

matRock.setFloat(“DiffuseMap_1_scale”, 16);

Texture rock = assetManager.loadTexture(“Textures/Terrain/splat/road.jpg”);


matRock.setTexture(“DiffuseMap_2”, rock);

matRock.setFloat(“DiffuseMap_2_scale”, 128);

Texture normalMap0 = assetManager.loadTexture(“Textures/Terrain/splat/grass_normal.jpg”);


Texture normalMap1 = assetManager.loadTexture(“Textures/Terrain/splat/dirt_normal.png”);


Texture normalMap2 = assetManager.loadTexture(“Textures/Terrain/splat/road_normal.png”);


matRock.setTexture(“NormalMap”, normalMap0);

matRock.setTexture(“NormalMap_1”, normalMap2);

matRock.setTexture(“NormalMap_2”, normalMap2);

AbstractHeightMap heightmap = null;

try {

heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 0.25f);


} catch (Exception e) {



terrain = new TerrainQuad(“terrain”, 65, 513, heightmap.getHeightMap());


terrain.setLocalScale(new Vector3f(5, 5, 5));

terrain.setLocalTranslation(new Vector3f(0, -30, 0));

terrain.setLocked(false); // unlock it so we can edit the height




private void initSky(){

rootNode.attachChild(SkyFactory.createSky(assetManager, “Textures/Sky/Bright/”, false));


private void initCamera() {

getCamera().setLocation(new Vector3f(0, 10, -10));

getCamera().lookAtDirection(new Vector3f(0, -1.5f, -1).normalizeLocal(), Vector3f.UNIT_Y);




This is the code for a minimal working example but the even stranger thing is that if I start the program showing the water and then disable it, it works fine.

How do you “disable”? Do you add the empty post processor still?

It’s the


In the simpleInitApp().

So I think I’m adding a fully built filter, just set to disable.

I guess he means this one

FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

Oh, does a disabled Filter count as empty?

I create the WaterFilter, add it to the post processor and then disable the filter.

…creating an empty post processor… like I said in the post you ignored, do the inverse of what you do to add the water, remove the processor.

I didn’t ignore your post, I just didn’t understand what you meant since I didn’t know that a Post Processor with a disabled Filter is equal to an empty PostProcessor since when you turn it off it works just fine.

I told you directly I didn’t understand, in that thread ("I think this is what you suggested but I’m not sure, can you confirm? "). When you answered “Your WaterFilter variable is null” i also didn’t understand. Since I indeed tried to remove the filter in the example of code I just showed so I assumed I wasn’t doing what you suggested.

I know you’re probably gonna ignore me from now on and I’m really sorry about that because I really value your input.

Just want you to know the only reason seem to ignore you is that I don’t know enough to understand what you are saying.

thats your interpretation of “the post you ignored”? my intention in “reminding” you is to hint at the fact that you might want to read back on answers people already gave to you as some information might become clearer after you gained other knowledge. else it can become frustrating quickly on the other side having to repeat things all the time.

Yes, that was my interpretation as ‘ignored’ usually has a bad connotation.

Happy to be wrong.

Anyway, it’s working fine now that I’m add and removing the whole PostProcessor.

So the setEnable(false) is for the case when there are several filters and we want to switch between them.

And it worked after I initialized it with an enabled filter because there are things that are only done in the init phase?

Just to learn a bit about the inside working of the engine as I make mistakes.

setEnable mainly allows disabling filters temporarily w/o changing the order, yes. It didn’t work as nothing was processing your scene in the empty filterPostProcessor, hence there was no output. I guess an empty PostProcessor could be handled a bit more graceful @nehon?