{"id":1248,"date":"2011-12-27T02:02:10","date_gmt":"2011-12-27T02:02:10","guid":{"rendered":"http:\/\/funkboxing.com\/wordpress\/?p=1248"},"modified":"2021-01-03T18:08:55","modified_gmt":"2021-01-03T18:08:55","slug":"blender-dynamic-paint-w-conways-life","status":"publish","type":"post","link":"http:\/\/funkboxing.com\/wordpress\/?p=1248","title":{"rendered":"Blender Dynamic Paint w\/ Conway&#8217;s Life"},"content":{"rendered":"<p><iframe loading=\"lazy\" src=\"http:\/\/www.youtube.com\/embed\/fxgGhBIXg94\" frameborder=\"0\" width=\"420\" height=\"315\"><\/iframe><\/p>\n\n\t\t<style type=\"text\/css\">\n\t\t\t#gallery-1 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 33%;\n\t\t\t}\n\t\t\t#gallery-1 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div id='gallery-1' class='gallery galleryid-1248 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='http:\/\/funkboxing.com\/wordpress\/?attachment_id=1252'><img width=\"150\" height=\"150\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" decoding=\"async\" loading=\"lazy\" srcset=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-150x150.jpg 150w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-300x300.jpg 300w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-96x96.jpg 96w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-24x24.jpg 24w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-36x36.jpg 36w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-48x48.jpg 48w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430-64x64.jpg 64w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0430.jpg 512w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='http:\/\/funkboxing.com\/wordpress\/?attachment_id=1253'><img width=\"150\" height=\"150\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" decoding=\"async\" loading=\"lazy\" srcset=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-150x150.jpg 150w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-300x300.jpg 300w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-96x96.jpg 96w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-24x24.jpg 24w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-36x36.jpg 36w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-48x48.jpg 48w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696-64x64.jpg 64w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/0696.jpg 512w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='http:\/\/funkboxing.com\/wordpress\/?attachment_id=1254'><img width=\"150\" height=\"150\" src=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" decoding=\"async\" loading=\"lazy\" srcset=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-150x150.jpg 150w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-300x300.jpg 300w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-96x96.jpg 96w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-24x24.jpg 24w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-36x36.jpg 36w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-48x48.jpg 48w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041-64x64.jpg 64w, http:\/\/funkboxing.com\/wordpress\/wp-content\/uploads\/2011\/12\/1041.jpg 512w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/dt><\/dl><br style=\"clear: both\" \/>\n\t\t<\/div>\n\n<p>This is an attempt to merge Blenders Dynamic Paint feature with cellular automata. It started as a python script but then became even more of an educational experience when I realized python wasn&#8217;t going to be fast enough to run conway&#8217;s life on a 64x grid, let alone a 4Kx one, which was my initial goal. These ended up being 512x grids. I could have gone bigger but I&#8217;m using a little netbook for all this so I didn&#8217;t go nuts.<\/p>\n<p>After figuring out that python wasn&#8217;t going to be fast enough I set out to make a c++ version, not in Blender, just in c++. Long story short it&#8217;s an atrocity of loops inside a main function. I didn&#8217;t even bother to pass any arguments, just recompiled every time I changed paths. Anyway it ended up being lots faster than the py scripts and I finally had an excuse to write a function I knew very well in a language I&#8217;ve been intimidated by for some time (and still very much am).<\/p>\n<p>The c++ code uses the ImageMagick++ library, which made things much easier, but you&#8217;ll have to get this lib if you want to compile and use this. Hopefully this whole process has prepared me to get on porting the lighting generator to c++, which really needs to happen if if it&#8217;s ever going to be more than a gimmick.<\/p>\n<p>So anyway, here&#8217;s the c++ code and here&#8217;s the Blender python script that I abandoned in favor of doing it in c++. For the record- this is bad, bad code. Very bad. Also here&#8217;s the command line to compile with g++ and imageMagick++, since that took awhile to get past.<\/p>\n<p><a href=\"http:\/\/funkboxing.com\/wordpress\/wp-content\/blendfiles\/conway_cpp_py.zip\">conway_cpp_py.zip<\/a><\/p>\n<p>user@pc:~$ g++ `Magick++-config &#8211;cxxflags &#8211;cppflags` conway.cpp -o conway `Magick++-config &#8211;ldflags &#8211;libs`<\/p>\n<p>Here&#8217;s the process for using this to dynamic paint with conways life.<\/p>\n<p>1) dynamically paint a canvas with a brush. This will paint &#8216;live&#8217; cells onto the canvas<br \/>\nTurn on &#8216;dissolve&#8217; and set to dissolve in 1-3 frames. Otherwise these become &#8216;immortal&#8217; cells, which makes for a weird simulation.<br \/>\nI used red channel only for these demos.<\/p>\n<p>2) compile and run the c++ code.<br \/>\nThis will run the simulation on the dynamic paint cache images. It runs the simulation from the initial frame, but always includes the red cells from the next dynamic paint frame so they will be used in the next simulation step.<\/p>\n<p>3) use this simulation output as a map in place of the dynamic paint output.<br \/>\nSounds easy, and it kind of is, and kind of isn&#8217;t.<br \/>\nSo if you want to do this yourself- if you know c++ it should be easy. If you don&#8217;t it will be very hard. If you&#8217;re just learning c++ it may be worthwile to try.<\/p>\n<p>Not sure where I&#8217;m going with all this, as usual it was just something to do. Hope you dig it.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is an attempt to merge Blenders Dynamic Paint feature with cellular automata. It started as a python script but then became even more of an educational experience when I realized python wasn&#8217;t going to be fast enough to run conway&#8217;s life on a 64x grid, let alone a 4Kx one, which was my initial <a href='http:\/\/funkboxing.com\/wordpress\/?p=1248' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,5,47],"tags":[],"_links":{"self":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1248"}],"collection":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1248"}],"version-history":[{"count":7,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1248\/revisions"}],"predecessor-version":[{"id":2615,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1248\/revisions\/2615"}],"wp:attachment":[{"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1248"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/funkboxing.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}