{"id":332,"date":"2011-12-16T22:56:35","date_gmt":"2011-12-16T19:56:35","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=332"},"modified":"2013-08-15T21:56:23","modified_gmt":"2013-08-15T18:56:23","slug":"metablob-shader-testin","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2011\/12\/16\/metablob-shader-testin\/","title":{"rendered":"Metablob shader testing"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"333\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2011\/12\/16\/metablob-shader-testin\/mblobshare1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2011\/12\/mblobshare1.jpg?fit=680%2C419&amp;ssl=1\" data-orig-size=\"680,419\" 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=\"mblobshare1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2011\/12\/mblobshare1.jpg?fit=680%2C419&amp;ssl=1\" class=\"alignnone size-full wp-image-333\" title=\"mblobshare1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2011\/12\/mblobshare1.jpg?resize=680%2C419\" width=\"680\" height=\"419\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2011\/12\/mblobshare1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2011\/12\/mblobshare1.jpg?resize=300%2C184&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><br \/>\nMetablob shader testing.<\/p>\n<p>2D metablobs..hmm..could this be used for (2D) fluids somehow?<\/p>\n<p><strong>Instructions:<\/strong><\/p>\n<p>&#8211; New scene<br \/>\n&#8211; Add plane, Location: 0,0,0\u00a0 Rotation: 0,0,0<br \/>\n&#8211; Add camera, Location: 0,10,0 Rotation: 90,0,0 (its looking down the plane)<br \/>\n&#8211; Add material using this shader to the plane, you should see some blobs (its using screenposition, so you might not see blobs in editor, depending on your view pos)<\/p>\n<p><strong>Download source:<\/strong><br \/>\n<a title=\"Download Source\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=258&amp;uid=un1t3c0d5r\" target=\"_blank\">blobshader.unityPackage<\/a><\/p>\n<p><strong>Shader source: (v1.0)<br \/>\n<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ ORIGINAL GLSL SHADER: 'Metablob' by Adrian Boeing (2011)\r\nShader &quot;mShaders\/mblob1&quot;\r\n{\r\nProperties\r\n{\r\n}\r\nSubShader\r\n{\r\nTags {Queue = Geometry}\r\nPass\r\n{\r\nCGPROGRAM\r\n#pragma target 3.0\r\n#pragma vertex vert\r\n#pragma fragment frag\r\n#include &quot;UnityCG.cginc&quot;\r\n\r\nstruct v2f {\r\nfloat4 pos : POSITION;\r\nfloat4 color : COLOR0;\r\nfloat4 fragPos : COLOR1;\r\n};\r\n\r\nv2f vert (appdata_base v)\r\n{\r\nv2f o;\r\no.pos = mul (UNITY_MATRIX_MVP, v.vertex);\r\no.fragPos = o.pos;\r\no.color = float4 (1.0, 1.0, 1.0, 1);\r\nreturn o;\r\n}\r\n\r\nhalf4 frag (v2f i) : COLOR\r\n{\r\nfloat animtime = _Time*10.0;\r\n\/\/the centre point for each blob\r\nfloat2 move1;\r\nmove1.x = cos(animtime)*0.4;\r\nmove1.y = sin(animtime*1.5)*0.4;\r\nfloat2 move2;\r\nmove2.x = cos(animtime*2.0)*0.4;\r\nmove2.y = sin(animtime*3.0)*0.4;\r\n\/\/screen coordinates\r\nfloat2 p = -1.0 + 2.0 * i.fragPos.xy \/ float2 (7,7);\r\n\/\/radius for each blob\r\nfloat r1 =(dot(p-move1,p-move1))*8.0;\r\nfloat r2 =(dot(p+move2,p+move2))*16.0;\r\n\/\/sum the meatballs \/\/ uh..typo maybe Oo?\r\nfloat metaball =(1.0\/r1+1.0\/r2);\r\n\/\/alter the cut-off power\r\nfloat col = pow(metaball,8.0);\r\n\/\/set the output color\r\nreturn float4(col,col,col,1.0);\r\n}\r\nENDCG\r\n}\r\n}\r\nFallBack &quot;VertexLit&quot;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Metablob shader testing. 2D metablobs..hmm..could this be used for (2D) fluids somehow? Instructions: &#8211; New scene &#8211; Add plane, Location: 0,0,0\u00a0 Rotation: 0,0,0 &#8211; Add camera, Location: 0,10,0 Rotation: 90,0,0 (its looking down the plane) &#8211; Add material using this shader to the plane, you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":333,"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":false,"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":[214,82,14],"class_list":["post-332","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-metaball","tag-metablob","tag-shader"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2011\/12\/mblobshare1.jpg?fit=680%2C419&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-5m","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/332","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=332"}],"version-history":[{"count":9,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions"}],"predecessor-version":[{"id":2276,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions\/2276"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/333"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}