Hacker News new | ask | show | jobs
by chengsun 4397 days ago
The trick is to perform damping around the edges in a hidden border around the heightmap. Say you wanted to simulate a 500x500 heightmap. You would actually calculate the results for a 700x700 heightmap, (which contains a hidden border of width 100 around each edge). The hidden edges are slowly damped away by multiplying by a factor interpolated between 1 (on the inner edge of the visible part of the heightmap) 0 (on the very outside of the heightmap).

This works remarkably well; you can see this approach in action in http://www.falstad.com/ripple/ for instance. Source code is included on the page.

1 comments

Thanks for the answer, I actually tried something like that but it never worked out completely. There always was a small residual amount of noise that prevented simulating a true infinite pool. I tried to come up with the necessary equations for the pool margins so that I wouldn't need a hack, but couldn't figure it out. One of those days I will!