Why does such a problem occur when using WaterMaterial?

When I rotate the “ground” and “waterMesh”, it will become like this.When I moved the camera, I could clearly sense two different refracted colors.Is it a problem with my code?Thanks for informing me.

expect:

but:

Maybe @julien-moreau would know as IIRC he was the daddy of it ?

1 Like

Hey @late-autumn-give-ear !

You can use water.disableClipPlane = true;
Updated playground: https://playground.babylonjs.com/?inspectorv2=true#1SLLOJ#4327

But according to the current angle it may cause “invisible reflections”, you’ll see what I mean when testing the updated playground. The water material was initially designed for surfaces that are parellel to the ground, the way reflections are computed may need an update. In that case @sebavan is there someone to focus on it in order to help me? I have already so much to do.

1 Like

That would be a nice update indeed i guess we should open a feature request on the forum for it to see how/when this can be addressed

1 Like

@late-autumn-give-ear It’s time to make your Christmas list :smiley:

ChatGPT:

When you rotate a mesh that uses Babylon.js WaterMaterial, its internal reflection and refraction buffers do not rotate with the mesh.
This creates the visual artifact you’re seeing: two mismatched colors, “slices,” or sliding distortions when the camera moves.

:white_check_mark: Why it happens

WaterMaterial renders the scene twice:

  1. Reflection pass (as if the water is a flat mirror)
  2. Refraction pass (objects seen through the water)

Both passes assume the water plane is axis-aligned:

water normal = (0, 1, 0)   // must face UP

When you rotate the mesh:

waterMesh.rotation = new BABYLON.Vector3(Math.PI/4, 0, 0);

…you break the assumption.
The material still thinks the water is horizontal, but the geometry is tilted, so reflection/refraction textures no longer map correctly → distorted colors and seams.

:cross_mark: You cannot rotate WaterMaterial meshes directly

In Babylon.js, the built-in WaterMaterial cannot lie on a slanted/rotated surface.
It must always be absolutely horizontal.

FIX:
water which skybox reflection but with plain color background | Babylon.js Playground

1 Like

Thank you.I got it :grinning_face:

2 Likes