{"id":1855,"date":"2013-04-12T18:04:33","date_gmt":"2013-04-12T15:04:33","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1855"},"modified":"2013-09-17T22:53:11","modified_gmt":"2013-09-17T19:53:11","slug":"water-particles-unity","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2013\/04\/12\/water-particles-unity\/","title":{"rendered":"Water Particles"},"content":{"rendered":"<p><a title=\"http:\/\/unitycoder.com\/upload\/demos\/WaterParticles1\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/WaterParticles1\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1857\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2013\/04\/12\/water-particles-unity\/water_particles_unity3d\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_unity3d.jpg?fit=680%2C383&amp;ssl=1\" data-orig-size=\"680,383\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"water_particles_unity3d\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_unity3d.jpg?fit=680%2C383&amp;ssl=1\" class=\"alignnone size-full wp-image-1857\" alt=\"water_particles_unity3d\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_unity3d.jpg?resize=680%2C383\" width=\"680\" height=\"383\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_unity3d.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_unity3d.jpg?resize=300%2C168&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Converted this javascript demo to Unity C#: <a title=\"http:\/\/www.dhteumeuleu.com\/aqualibrium\" href=\"http:\/\/www.dhteumeuleu.com\/aqualibrium\" target=\"_blank\">Aqualibrium by Gerard Ferrandez<\/a><\/p>\n<p><strong>Info:<\/strong><br \/>\n&#8211; Had to make some modifications since all those javascript [this] that.x variables were quite complicated..but seems to work \ud83d\ude42<br \/>\n&#8211; Screenshot shows 500 spheres with debug.drawlines to each neighbour particle (added gravity on by default)<\/p>\n<p><strong>Current version:<\/strong><br \/>\n&#8211; Got distance calculation bit faster (mainloop went from: 192ms for 1500 particles, to: 104ms for 1500 particles) (debug.linedraw is on): using this sphere <a title=\"http:\/\/freespace.virgin.net\/hugo.elias\/routines\/r_dist.htm\" href=\"http:\/\/freespace.virgin.net\/hugo.elias\/routines\/r_dist.htm\" target=\"_blank\">Distance Between 2 points<\/a><br \/>\n&#8211; If I use default sphere as prefab for the particle, it doesnt get batched, but default cube does ..Oo?<\/p>\n<p><strong>TODO:<\/strong><br \/>\n&#8211; 3D version?<br \/>\n&#8211; Add Blobmesh = water?<br \/>\n&#8211; Optimize..if can..<br \/>\n&#8211; Different fluidish materials? (mass, friction, break-ability?)<br \/>\n&#8211; Sand simulation? (ground digging with excavator..or maybe better using the eulerian water sim grid?)<br \/>\n&#8211; Test threading? <a title=\"http:\/\/unitygems.com\/threads\/\" href=\"http:\/\/unitygems.com\/threads\/\" target=\"_blank\">http:\/\/unitygems.com\/threads\/<\/a><\/p>\n<p><strong>Webplayer:<br \/>\n<\/strong><a title=\"http:\/\/unitycoder.com\/upload\/demos\/WaterParticles1\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/WaterParticles1\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/WaterParticles1\/<\/a> (500 particles)<br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/WaterParticles2\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/WaterParticles2\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/WaterParticles2\/<\/a> (additive particle shader)<\/p>\n<p><strong>Download source:<\/strong><br \/>\n<a title=\"Download Source\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=1313&amp;uid=un1t3c0d5r\" target=\"_blank\">waterParticles.unitypackage<\/a><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#2:<\/strong> Testing threading with 1500 cubes.. its fast &amp; kind of works, but some particles wont slown down at all..<br \/>\n<a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/unity3d_threading_test.jpg\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1869\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2013\/04\/12\/water-particles-unity\/unity3d_threading_test\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/unity3d_threading_test.jpg?fit=1290%2C752&amp;ssl=1\" data-orig-size=\"1290,752\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"unity3d_threading_test\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/unity3d_threading_test.jpg?fit=1024%2C596&amp;ssl=1\" class=\"alignnone size-medium wp-image-1869\" alt=\"unity3d_threading_test\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/unity3d_threading_test-300x174.jpg?resize=300%2C174\" width=\"300\" height=\"174\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/unity3d_threading_test.jpg?resize=300%2C174&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/unity3d_threading_test.jpg?resize=1024%2C596&amp;ssl=1 1024w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/unity3d_threading_test.jpg?w=1290&amp;ssl=1 1290w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>(click for full size)<\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#3<\/strong>: Nice idea here..but it would pretty much need unity pro: <a title=\"http:\/\/www.patrickmatte.com\/stuff\/physicsLiquid\/\" href=\"http:\/\/www.patrickmatte.com\/stuff\/physicsLiquid\/\" target=\"_blank\">http:\/\/www.patrickmatte.com\/stuff\/physicsLiquid\/<\/a><br \/>\nTried with additive particle shader instead:<br \/>\n<a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_blue_shader_unity3d.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1873\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2013\/04\/12\/water-particles-unity\/water_particles_blue_shader_unity3d\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_blue_shader_unity3d.jpg?fit=1281%2C653&amp;ssl=1\" data-orig-size=\"1281,653\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"water_particles_blue_shader_unity3d\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_blue_shader_unity3d.jpg?fit=1024%2C521&amp;ssl=1\" class=\"alignnone size-medium wp-image-1873\" alt=\"water_particles_blue_shader_unity3d\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_blue_shader_unity3d-300x152.jpg?resize=300%2C152\" width=\"300\" height=\"152\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_blue_shader_unity3d.jpg?resize=300%2C152&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_blue_shader_unity3d.jpg?resize=1024%2C521&amp;ssl=1 1024w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_blue_shader_unity3d.jpg?w=1281&amp;ssl=1 1281w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>(click for full size)<\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#4<\/strong>: Scaling particles based on neighbour count (would be also interesting to stretch them based on speed..)<br \/>\n<a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_scaled_unity3d.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1877\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2013\/04\/12\/water-particles-unity\/water_particles_scaled_unity3d\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_scaled_unity3d.jpg?fit=839%2C752&amp;ssl=1\" data-orig-size=\"839,752\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"water_particles_scaled_unity3d\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_scaled_unity3d.jpg?fit=839%2C752&amp;ssl=1\" class=\"alignnone size-medium wp-image-1877\" alt=\"water_particles_scaled_unity3d\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_scaled_unity3d-300x268.jpg?resize=300%2C268\" width=\"300\" height=\"268\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_scaled_unity3d.jpg?resize=300%2C268&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_scaled_unity3d.jpg?w=839&amp;ssl=1 839w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>(click for full size)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Converted this javascript demo to Unity C#: Aqualibrium by Gerard Ferrandez Info: &#8211; Had to make some modifications since all those javascript [this] that.x variables were quite complicated..but seems to work \ud83d\ude42 &#8211; Screenshot shows 500 spheres with debug.drawlines to each neighbour particle (added gravity [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1857,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[68,759,228,477,60],"class_list":["post-1855","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-c","tag-particles","tag-physics","tag-repel","tag-water"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/water_particles_unity3d.jpg?fit=680%2C383&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-tV","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=1855"}],"version-history":[{"count":20,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1855\/revisions"}],"predecessor-version":[{"id":2425,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1855\/revisions\/2425"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1857"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}