Water and light
Saturday, February 24th, 2018This weekend I got a lot of items done! The core engine is somewhat working, and the most fun bit has been trying to work out the interactions between water and light.
-Phil
Phil Hassey - game dev blog | |
".. I've been there,
I know what it's like, and I'll do it again if I have to." |
This weekend I got a lot of items done! The core engine is somewhat working, and the most fun bit has been trying to work out the interactions between water and light.
-Phil
I spent most of my time working on improving the water flow algorithm. As it turns out, I couldn’t find any real improvements, so it’s not visually any different than last week. Code-wise, it’s maybe a bit better.
To say I got something done, I added in basic auto-tiling and a barely functioning editor.
Nothing too fancy, but hopefully I can add gameplay sometime soon. Will probably build up the editor more first.
-Phil
After a while I found re-working the water algorithm in C++ was taking too long. I recoded it in Lua with a much lower resolution and numbers over the water so I could see exactly what was happening.
I first reproduced the classic demo-scene effect. The problem with this effect is that it does not maintain volume at all, it is a rapid simulation of the waves only.
I found an algorithm that would preserve volume, however it was very slow and did not have a very wavy / water feel to it. I’m not even sure if I implemented it right.
I did a lot of experimenting with different ideas until I made one that did work! This effect is wavy and maintains volumes. It also settles down over time. Quite a few of my experiments would never result in a calm pool.
I then re-coded it into C++. Initially I was disappointed to see it not work at all, but I found by adjusting the parameters I was able to get the effect I want. With a larger area for the waves to wave in, they behaved much differently than in a small area.
I did a bit of optimization work on the algorithm and the rendering and it now works at a decent speed even for large bodies of water.
-Phil