Log in to follow projects

Following a project allows you to receive updates via email. It also lets the owner know that you like them.


Mini Planet Demo

By Oliver Smith

An icosphere with heightmap-based dynamic water on the GPU and a deformable land mesh.

30% complete
1 follower 2845 views
About Log Discussion (0)

Got it (mostly) working!

A while back I was playing around with heightmap-based fluid simulation as described in this paper and seen in games like Arcane Worlds and (I think) From Dust. I had some code working on a flat grid on the CPU, but I wanted to learn how to do it on the GPU as well, so that's what I did over the last few days - thanks a lot to ScrawkBlog which gave me some code to reference.

The hard part is not actually the fluid dynamics which are pretty simple (it's not really that great of a fluid simulation), but getting it to run in shaders which are extremely hard to debug. Massaging all your data into color textures and then reconstructing the data on the GPU is not the simplest thing in the world. I also ran into some really weird issues where Unity seemed to be optimizing out variables I was passing to my shaders (or something), meaning some calculations were just not working at all even though the numbers were all correct. I definitely made it a lot harder by doing it on a sphere because the cell neighbors are not easily accessible - I had to implement a lookup table in a texture and use two textures for storing up to 6 outflow velocities instead of the one texture you'd need to store 4 velocities in a grid-based implementation.

I want to keep working on this since I'm learning a ton about shader techniques - next up I need to figure out some kind of edge smoothing so the land and water blend together seamlessly. Right now there's some ugly flickering.

Here's a terrible quality gif (although it probably looks cooler here since the gif makes it look higher resolution than it actually is):