Stylized Water Shader

My initial idea was to share this wave functionality in Lua. Then I thought it might be better to move it to a separate extension as a general-purpose C++ native extension. That is why this is taking longer than I mentioned before.

Now it is possible to use it with a water shader or in any project that needs wave-driven, kind of floating objects.

Consider this a fun project. I highly recommend that you test it for your needs before using it in production. You may also want to use a fixed update, which is also possible with a small change to the C++ update, or pass the timing from Lua to C or vice versa for more solid synchronization. You may also run into floating point precision issues after hours or days, depending on the speed. There are different ways to address this, and how you choose to handle it is entirely up to you.

There are two simple examples to test it. It may take some time to load since texture compression causes this issue with cubemaps, so I had to disable it:
Boat: https://selimanac.github.io/defold-wave/boat/
Ducks: https://selimanac.github.io/defold-wave/ducks/

12 Likes