WebGPU Ocean - artifacts on other meshes in scene and buoyancy issues

Hi - @Evgeni_Popov - quick question for you about your amazing ocean code. When I add it to a scene with other meshes those other meshes gain some artifacts. Seems like it’s mostly meshes that are far away from the camera. I’m thinking that the shader is picking up some of the vertices from these other meshes?

Any advice on what to tweak or where to look to reduce that artifacting? Here’s a video (easier to see at full size):

And a PG:

(you kinda have to zoom around to the front to see it)

It seems to be an anti-aliasing problem. Try to enable MSAA on the FXAA post-process:

See line 170.

4 Likes

Awesome! So much better. Thx so much.

Dude did u make that level inside your babylon editor or is that a unity export?

Yes, inside babylon editor. Although buildings/roads/etc are already in place from the GLB asset made in Blender.

ahh. looks good, was hoping we had a level editor incomming:(

Im so close to glory with this! Have been trying to write a function to drop an arbitrary mesh into the ocean and have it float - and then allow characters to ride the floating object (boats).

Primary questions:

  • Why do colliders stop working? When i have my character jump onto boats, it falls through. Not shown in PG, but you can that the boats are riding on top of piers and such. You can test character in this demo; type commands “add ocean” and then “make boats float” - you can see colliders work before the “make float” command.
  • Why does foam contact not work?

There are some other issues, but think i’ve got an idea for those.

See addMeshToOcean

I wrote comments in there to try to explain frame and spaceCoordinates, which i played around with a ton and now just happen to have a combo that works. Would love to be able to determine these programmatically, but couldn’t write anything that worked as well as the default settings for boat.

Oooh, collider issue must be because i’ve flipped the mesh.scaling.z
Yea, that’s it.
Hm, that was was the only way i could figure to get the boats right side up.


Collider working! ^, but boats capsized.

1 Like

Never use negative scaling if you want to avoid problems :slight_smile:

You can rotate your boat 180° around the right axis (X or Z)?

Yep - that works!

Modified the the _updateMesh function.

And i got some clue about the contact foam. It works when i load in a new mesh instead of picking from one of the meshes that already has a parent. And of course the rotation is not working the same! But hey, it’s a clue.

You push in the depth renderer the children of a boat, but not the boat itself:

2 Likes

Got it re depth renderer!
Hey, have y’all noticed using this ocean demo (or maybe webgpu) that it slows down over time? On my machine the ocean PG demo goes from 55-60fps to 10fps over time with no other chrome windows open. After a chrome quit and restart, it remains at 10fps. Seems like it may happen after opening the demo in 2 different tabs simultaneously - like the memory is not released. Only computer reboot solves.

Very occasionally, there is a gpu-crash error as well (that resolves with a quit/restart of Chrome). Maybe related?

i’ve been trying like heck to get other types of boats to float. i’m wondering if there’s a bug with the setting of point v1. in the debugger i made, it jumps back and forth irregularly (unlike the other points).

here, in this pg, i’ve got he points almost exact same as the fisherboat, but the boat floats wildly.

Points are:
Red v1, Green v2, Blue v3

Here’s where i got them set in the pg (inverted in terms of front/back of boat, but i dont think that matters); just doesn’t want to float - and you’ll notice the Red sphere flickering back and forth in this PG and in the original.

What’s important regarding the 3 points P1, P2 and P3 is that the P1P2 vector gives the “forward” direction, and P1P3 the “left” direction. They should be orthogonal, and only a single value among the three x/y/z axis should be non null in P1P2 and P1P3. Also, P1/P2/P3 should be in the local space of the mesh.

Here’s a setup that works in your case:

3 Likes

That answers so many questions. Thank you!!

1 Like