Water material that works above and below water?

Does anyone have a water material example that works when the camera goes underwater?

I think I remember seeing an example in the old forum.

An example that looks similar to this underwater would be great.

Here is one example - https://playground.babylonjs.com/#3HIEUF#6


And more here - Weekly Video: Introducing the Mystery Demo Tutorial Series - #12 by PirateJC

1 Like

I have a few examples of this “floating” around in PG’s you might be able to search for them.

Ew Ignore this actually… it does not work anymore I gotta fix it.

Here you go.

2 Likes

That is beautiful. I need to be able to look up at the surface of the water from below, though. I’ll probably just make my own water using a shader if I can’t get it done with water material.

I know this is an old thread and sorry for bumping it, but I’m working on a shader for underwater (works above water too). I’ll make a post pretty soon about the application, including this shader and other stuff I’m finishing, but I ran into this thread today and I’m linking it here for @adam and anyone else who finds this page in the future.

The shader code is here, which is a variation of the old ocean postprocessing code, commented and reviewed. I’m not sure if I’ll have time to fix it, but hopefully I’ll fix the ray marching code for when the camera very close to the water line, which doesn’t work well. BTW, it’d be nice to have a proper ray marching example with a stable algorithm in the docs or as a sample. If I get to fix it properly (and there’s also a nasty hack for the FOV, which is hardcoded and needs to be fixed) I’ll write a doc about it and send the PR.

The code is a bit tied to the application since it also renders the sky, which is good for performance but not as general as it should be. If anyone is interested in helping to make it more generic, it wouldn’t be too hard to release a separate repo with this PostProcessing as a plugin (to avoid the Apache/Creative common issues).

4 Likes

This looks so coool !!! I now want a surf/kite surf/wind surf game where obviously, if realistic enough, I ll spend a lot more time under the water than above :wink:

2 Likes