Liquid and gas shaders
Being stuck in the weeds continues, with great success! Over the last two weeks I have focused on the rendering code for the game, to make the game more pleasant to look at.
Using a concept I’m calling “texture offsets”, tiles keep track of their relative movement, which allows the illusion of gas expanding:
And even more importantly, I’ve managed to get liquids looking more… liquidy.
To achieve these effects (at 60fps+) has required me to learn a lot about GLSL shaders, more than I ever expected. I am indebted to some of the incredible online resources I’ve found, such as Shadertoy, The Book of Shaders, Making Stuff Look Good, this GLSL quick reference PDF, and Lygia (shader library). And my new friend Oisin!
It’s still a deep and dark black magic but I’ve learned a lot.
The rendering is still quite blocky (a tile with 1kg of liquid looks the same as one with 1000kg), which I think I’ll tackle next. I think doing something simple with static masks will probably work fine, but ideally I’d love to have something generated on the fly (which would save me having to make hundreds of mask textures).