WaterFilter and SpotLightShadowRenderer

Hey,
playing around with the Waterfilter I noticed a strange thing: When using the SpotLightShadowRenderer and a WaterFilter and no other light source than a spotlight I can see through my models. Here are screenshots:

As soon as I use only one of the two it is working fine. This is the code I use:

[java]private void initLight() {
flashlight = new SpotLight();
flashlight.setSpotRange(45);
flashlight.setSpotOuterAngle(30 * FastMath.DEG_TO_RAD);
flashlight.setSpotInnerAngle(20 * FastMath.DEG_TO_RAD);
flashlight.setPosition(app.getCamera().getLocation());
flashlight.setDirection(app.getCamera().getDirection());
flashlight.setColor(ColorRGBA.White.mult(1.6f));
app.getRootNode().addLight(flashlight);

    slsr = new SpotLightShadowRenderer(app.getAssetManager(), 1024);
    slsr.setLight(flashlight);
    slsr.setShadowIntensity(0.5f);
    app.getViewPort().addProcessor(slsr);
}

private void initTerrainSecondLevel() {
terrain = app.getAssetManager().loadModel(“Scenes/City.j3o”);
terrainControl = new RigidBodyControl(0.0f);
terrain.addControl(terrainControl);
terrain.setShadowMode(RenderQueue.ShadowMode.Receive);
pM.add(terrainControl);
app.getRootNode().attachChild(terrain);

    FilterPostProcessor fpp = new FilterPostProcessor(app.getAssetManager());
    WaterFilter water = new WaterFilter(app.getRootNode(), Vector3f.ZERO);
    water.setLightColor(ColorRGBA.Black);
    water.setWaterHeight(-4f);
    water.setLightDirection(Vector3f.ZERO);
    water.setRadius(35);
    water.setCenter(new Vector3f(72.50758f, -5.8953094f, 2.7464912f));
    fpp.addFilter(water);
    app.getViewPort().addProcessor(fpp); 
}

What did I do wrong?

I solved it by adding the FilterPostProcessor after adding the ShadowRenderer.

1 Like