Devblog
Water interactions

Water interactions

I got so lucky with creating the water interactions! I managed to find a water interaction demo project made with unity 5! I loaded it up into my current version 2020.2b and managed to get it working with a few tweaks to the source code. I frankensteined the project into small pieces and brought them into my project one by one until it’s render-texture component started working. Now I had a wave pattern generating texture on my disposal! All I needed to do was to create the code that adds to it and the shader that reads from it!

Interactive water shader first pass

When I was working on effects at Remedy on Quantum Break, our AD / Tech magician, Janne Pulkkinen, had created this soundwave*ish effect that flowed trough the world when the main character Jack was using his time powers. To get the effect to span the whole level, he looped the texture infinitely over the whole world and you could write into it from anywhere in the world. I figured I would do the same! I would read the texture in world space and use it to distort my wave array. My wave objects are smaller, 10 by 10 meter squares that are placed all over the world. I used small pieces so that I would not have to be rendering all the water all the time, but instead it would be split into cullable segments and I could also use GPU instancing for speed.

The water shader world space height map graph

Adding the world space placement for the water was easy. All I needed to do was read the pixel world space, multiply it by my scale and add the offset and then add it on top of my noise wave pattern on the Y vertex position.

I imagined creating the bits that write to the render texture at world space would not be much harder, and I was right. I could use Mathf.Repeat(pos, 1) function to strip the integers off of my influencer world position. Multiplying this position with the same scale value allowed me to write on the height map everywhere in the world and have the water interaction be displayed exactly where it was supposed to be. Just like in Quantum Break!

I now have a water surface that interacts beautifully with my mouse clicks. This, however, has no value in the game. Next I will be creating functionality for ships and other objects to add waves on the water and I might create buoyant physical objects while I am at it.

One interesting problem to solve will be the big cargo ships tail wave. I need to have the water with simulations constantly looping under the ship and I also need to figure out a way to add awesome lowpolygon foam for the big wave. I can not wait to get started on that!

Seeing sounds

With this shader trick, I will also be prototyping a scenario where you play as a blind person and the only way you can see is by making or hearing sounds. I will use the same render texture as with waves to visualise the sounds propagating trough the world.


Leave a Reply