{"author_name":"zzorn","cat":"LD #29","comments":[],"epoch":1398532680,"likes":1,"metadata":{"p_key":"31710","p_author":"zzorn","p_authorkey":"2534","p_urlkey":"67205","p_title":"Making Physically Accurate Bubbles","p_cat":"LD #29","p_event":"LD29","p_time":"1398532680","p_likes":"1","p_comments":"0","p_status":"UPD5","us_key":"2534","us_name":"zzorn","us_username":"zzorn","event_start":"1398384000","event_key":"22","event_name":"LD29"},"text":"<p>I&#8217;m building a submarine dogfight simulator.<\/p>\n <p>So far I finished the underwater physics and basic rendering.\u00a0 And also pretty bubbles!<\/p>\n <p><a href=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/CrushingDepth_so_physical_bubbles_03.png\"><img class=\"aligncenter size-full wp-image-346820\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/CrushingDepth_so_physical_bubbles_03.png\" alt=\"CrushingDepth_so_physical_bubbles_03\" width=\"573\" height=\"459\" srcset=\"http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/CrushingDepth_so_physical_bubbles_03-300x240.png 300w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/CrushingDepth_so_physical_bubbles_03-550x440.png 550w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/CrushingDepth_so_physical_bubbles_03.png 573w\" sizes=\"(max-width: 573px) 100vw, 573px\" \/><\/a><\/p>\n <p>The physics got pretty complicated &#8212; apart from normal gravitation and velocity updates there is buoyancy that depends on the density of the surrounding fluid, and the density in an ocean changes very slowly and non-linearily when going deeper, based on the temperature, salinity and pressure.\u00a0 In the end I approximated the density formula based on looked up values.\u00a0 The drag depends on the current velocity, density, object front area, as well a shape dependent experimentally discovered drag coefficient (can be approximated as 0.04 or so for streamlined shapes).<\/p>\n <p>Where things get really hairy are in the bubbles though &#8211; the volume (and thus density) of an air bubble changes depending on the surrounding pressure and temperature.\u00a0 Fortunately it was easy to recalculate the density (and display radius) for bubble entities on each frame, which can then be used by the rest of the physics system.\u00a0 So the bubbles expand in a realistic way when they get close to the water surface, and larger bubbles rise faster than smaller.\u00a0 There is also some turbulent sideways movement (in addition to prevailing current) for bubbles, which I approximated with some noise functions.<\/p>\n <p>So, I&#8217;ve got some pretty bubbles, and placeholder submarines.\u00a0 Still one day to add actual gameplay and all the rest&#8230; <img src=\"http:\/\/ludumdare.com\/compo\/wp-includes\/images\/smilies\/simple-smile.png\" alt=\":)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/><\/p>","time":"April 26th, 2014 12:18 pm","title":"Making Physically Accurate Bubbles"}