Terrain edge see through WaterFilter

Hi all.
I have this problem where one can see the terrain edge through the WaterFilter.
I want to here from the community what would be the best solution for this problem?

3 Likes

So it seems much better when I change the water color to be the same as the deep water color.
Like this screenshot.

And in game it looks like this!

2 Likes

I had the same issue and needed to add a gigantic quad (A PolygonFrame actually) under water.

Will test your solution as well, thanks for the finding :slightly_smiling_face:

1 Like

Unfortunately, it did not help in my case.

I used ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f); for both waterColor and deepWaterColor

1 Like

Have you tried to adjust the transparency?
I had to play around with the other settings as well.

1 Like

Yep, no difference.

Here is my setup:


        // Setup Water
        //--------------------------------------
        Node root = ApplicationGlobals.getInstance().getRootNode();
        Node empty = new Node();
        root.attachChild(empty);
        water = new WaterFilter(empty, sun.getDirection());//getState(SceneGraphState.class).getReflectiblesNode()
        water.setLightColor(sun.getColor());
        water.setReflectionMapSize(16);
        water.setUseFoam(true);//false
        //water.setUseRipples(false);
        water.setWaterHeight(-6f);//0.4f
        water.setUseRefraction(true);//false
        //water.setRadius(200);
        //water.setCenter(new Vector3f());
        water.setUseHQShoreline(true);//false
        water.setDeepWaterColor(new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f));
        water.setWaterColor(new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f));
        water.setWaterTransparency(1.2f);//2 // 1.6 //0.6f
        //water.setMaxAmplitude(0.6f);
        //water.setWaveScale(0.001f); // 0.008f //0.18f
        water.setSpeed(0.7f);//0.7f //0.38f
        water.setShoreHardness(0.001f);//0.01f
        //water.setFoamHardness(0.3f);//1
        water.setFoamIntensity(0.1f);// 0.2f
        //water.setRefractionConstant(1f); // 0.17
        //water.setRefractionStrength(0.28f); // 0
        water.setReflectionDisplace(2);
        //water.setShininess(0.22f);// 0.9f
        water.setSunScale(1);//3.0f
        //water.setNormalScale(0.1f);//0.06 //0.03f
        water.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));

        water.setUseSpecular(false);
        water.setUseRipples(false);

Ok, increasing RefractionStrength solved it! :slightly_smiling_face:

2 Likes

@ndebruyn are you using SkyControl library for the sky?

No I am not.
I am using a normal Sphere in the Sky Bucket.
I do however have a lineargradient shader that I wrote for the color gradient.

            Sphere sphere = new Sphere(50, 50, 500, false, true);
            Geometry sky = new Geometry("sky", sphere);
            sky.setQueueBucket(RenderQueue.Bucket.Sky);
            sky.setCullHint(Spatial.CullHint.Never);
            sky.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO));
            //TODO: Need to find a solution to make the sky stick to the camera
            //sky.addControl(new CameraStickControl(camera));

            Material m = new Material(assetManager, "MatDefs/lineargradient.j3md");
            m.setColor("StartColor", ColorUtils.rgb(2, 107, 187));
            m.setColor("EndColor", ColorUtils.rgb(190, 221, 253));
            m.setFloat("MinStep", 0.27f);
            m.setFloat("MaxStep", 0.47f);
            m.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Back);
            sky.setMaterial(m);
2 Likes

I see, just wanted to mention that for those who are using the SkyControl library, for Day/Night light to be properly applied to water one needs to add the water ReflectionView to the sky updater.

    WaterFilter water = fpp.getFilter(WaterFilter.class);
    if (water != null) {
        sc.getUpdater().addViewPort(water.getReflectionView());
    }
3 Likes