{"id":1575,"date":"2018-02-03T12:16:08","date_gmt":"2018-02-03T18:16:08","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/?p=1575"},"modified":"2018-02-03T21:03:16","modified_gmt":"2018-02-04T03:03:16","slug":"water-effects-part-2","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2018\/02\/03\/water-effects-part-2\/","title":{"rendered":"Water effects (part 2)"},"content":{"rendered":"<p>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.<\/p>\n<p><a href=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/protoScreenSnapz014.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/protoScreenSnapz014.png\" alt=\"\" width=\"859\" height=\"861\" \/><\/a><\/p>\n<p>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.<\/p>\n<p><a href=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-03-2018-11-07-42.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1579\" src=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-03-2018-11-07-42.gif\" alt=\"\" width=\"434\" height=\"436\" \/><\/a><\/p>\n<p>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&#8217;m not even sure if I implemented it right.<\/p>\n<p><a href=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-03-2018-11-08-02.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1578\" src=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-03-2018-11-08-02.gif\" alt=\"\" width=\"434\" height=\"436\" \/><\/a><\/p>\n<p>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.<\/p>\n<p><a href=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-03-2018-11-08-27.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1577\" src=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-03-2018-11-08-27.gif\" alt=\"\" width=\"434\" height=\"436\" \/><\/a><\/p>\n<p>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.<\/p>\n<p><a href=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-02-2018-19-37-57.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1580\" src=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2018\/02\/Feb-02-2018-19-37-57.gif\" alt=\"\" width=\"516\" height=\"374\" \/><\/a><\/p>\n<p>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.<\/p>\n<p>-Phil<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128,129],"tags":[],"class_list":["post-1575","post","type-post","status-publish","format-standard","hentry","category-featured","category-proto"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/1575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=1575"}],"version-history":[{"count":5,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/1575\/revisions"}],"predecessor-version":[{"id":1585,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/1575\/revisions\/1585"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=1575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=1575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=1575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}