Simple water - volume above the water plane

Hi again all.



I’m working on implementing simple water. I’ve pretty much got it working except for an artifact issue that’s a bit hard to explain. Unfortunately I can’t post screenshots right now, so I’ll give it a try.



Picture a large flat terrain with a square hole in the terrain. The hole is 1 unit deep. I’ve set the water plane just barely below the terrain so that when you look into the hole you see the water. The water itself looks good, shadows are working, but it looks like there’s a block directly above the water, translucent. It almost looks like the hole in the terrain has been raised above the water line and turned into a solid mass of water. Very see through - hardly visible in first person camera but really stands out in third-person camera view.



I’m pasting the water code below…I’m sure someone will look at this and it’ll be obvious where I’ve screwed up…right? : )



waterProcessor = new SimpleWaterProcessor(assetManager);

waterProcessor.setReflectionScene(drawNode);

waterLocation = new Vector3f(0,0.8f,0);

waterProcessor.setPlane(new Plane(Vector3f.UNIT_Y, waterLocation.dot(Vector3f.UNIT_Y)));

waterProcessor.setWaterDepth(.1f); // transparency of water

waterProcessor.setDistortionScale(0.025f); // strength of waves

waterProcessor.setWaveSpeed(0.01f); // speed of waves

waterProcessor.setWaterColor(ColorRGBA.Blue);

waterProcessor.setRenderSize(1024,1024);

viewPort.addProcessor(waterProcessor);



Quad quad = new Quad(2048,2048);

quad.scaleTextureCoordinates(new Vector2f(6f,6f));

water = new Geometry(“water”, quad);

water.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));

water.setLocalTranslation(0, 0.8f, 2048);

water.setShadowMode(ShadowMode.Receive);

water.setMaterial(waterProcessor.getMaterial());

rootNode.attachChild(water);

Hard to tell without a screen shot but try to play with the setRefractionClipingOffset and setReflectionClipingOffset.

setReflectionClippingOffset…looks great now, thank you!