I try to mix the “Water” and “Raycast on Height Map” samples to let the Sphere float on water surface but seem that this surface do not change its vertices positions like in height map!
Hi @NRA Tough one, i believe the water material is a pure shader effect, the “waterMesh” isn’t actually updated, so neither is it’s vertex positions.
Aka. no matter the waves, vertex position Y values are always 0.
@aWeirdo seems to be correct, but luckily it’s just one line of code to port! Here is a playground with the vertex position code from water.vertex.fx put into registerBeforeRender:
I did the first post but had an unexpected event and just today I am returning to it! And guess what! It is brightly solved and recommended to listed in the Babylon site samples!
OMG, amazing news to start this week!
Glad it works for you!
As for the PR, here’s a nice playground, with a separate getWaterHeightAtCoordinates that’s easy to “play” with, the only problem is that waterMaterial._lastTime is actually a private variable in TypeScript, so I’m not sure if it’s a good example for the doc… @Deltakosh?
Is there an easy way to have a more realistic floating effect? Like rotating the ball to match the wave angle, sort of like it is riding a wave. Might be easier to see with a box, rather than a ball. Might have to try that later at some point.
Depends how the mesh is made i suppose
here i added a “__rotationAxis” vector3, so for each axis: 0 = no rotation, 1 = full rotation, -1 reversed rotation, etc.
I am new to Babylon.js and I wanted to replicate the floating sphere on water material (https://www.babylonjs-playground.com/#L76FB1#49) example but using a boat model mesh instead of the sphere. The math that creates the floating seems to be working fine, but I can’t figure out how to prevent the water from getting inside the boat. Is there anybody who might have a clue on how to solve this?