SimpleWater, reflections and transparency

Hello. I’m sure there’s an easy answer for this.

I’m playing around with the SimpleWaterProcessor, but I can’t make it transparent - it just reflects the surrounding scene and doesn’t show the texture on the waterbed beneath the surface. Is SimpleWaterProcessor capable of this?

Here’s how I set it up:

[java]SimpleWaterProcessor waterProcessor = new SimpleWaterProcessor(app.getAssetManager());
waterProcessor.setReflectionScene(worldNode);

Vector3f waterLocation = new Vector3f(0,-3,0);
waterProcessor.setPlane(new Plane(Vector3f.UNIT_Y, waterLocation.dot(Vector3f.UNIT_Y)));
app.getViewPort().addProcessor(waterProcessor);

waterProcessor.setWaterDepth(40);
waterProcessor.setDistortionScale(0.05f);
waterProcessor.setWaveSpeed(0.05f);
waterProcessor.setWaterTransparency(0.05f);
waterProcessor.setLightPosition(new Vector3f(-4.9f, -1.3f, 5.9f));

Geometry water = waterProcessor.createWaterGeometry(1000, 1000);
water.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
water.setLocalTranslation(-500, -3, 500);
water.setShadowMode(ShadowMode.Receive);
water.setQueueBucket(Bucket.Transparent);
water.setMaterial(waterProcessor.getMaterial());
rootNode.attachChild(water);[/java]

yep, easy solution…not completely intuitive though :stuck_out_tongue:
you have to play with the refractionConstant parameter. It weights how much the reflection will be visible.
for example you can try :
water.setRefractionConstant(0.05f);

I know that it’s called refractionConstant and not reflectionConstant, but it’s actually really a refraction constant. It just happen that the visual effect makes the reflection less visible for low values.

Hm, I don’t see a way to set the refraction constant in the SimpleWaterProcessor… am I missing something?

oh uh sorry I thought you were talking about the WaterFilter

ok for the water processor, the water transparency works the other way around the higher value the more transprent will be the water