16
2011
Metablob shader testing

Metablob shader testing.
2D metablobs..hmm..could this be used for (2D) fluids somehow?
Instructions:
– New scene
– Add plane, Location: 0,0,0 Rotation: 0,0,0
– Add camera, Location: 0,10,0 Rotation: 90,0,0 (its looking down the plane)
– 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)
Download source:
blobshader.unityPackage
Shader source: (v1.0)
// ORIGINAL GLSL SHADER: 'Metablob' by Adrian Boeing (2011)
Shader "mShaders/mblob1"
{
Properties
{
}
SubShader
{
Tags {Queue = Geometry}
Pass
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : POSITION;
float4 color : COLOR0;
float4 fragPos : COLOR1;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.fragPos = o.pos;
o.color = float4 (1.0, 1.0, 1.0, 1);
return o;
}
half4 frag (v2f i) : COLOR
{
float animtime = _Time*10.0;
//the centre point for each blob
float2 move1;
move1.x = cos(animtime)*0.4;
move1.y = sin(animtime*1.5)*0.4;
float2 move2;
move2.x = cos(animtime*2.0)*0.4;
move2.y = sin(animtime*3.0)*0.4;
//screen coordinates
float2 p = -1.0 + 2.0 * i.fragPos.xy / float2 (7,7);
//radius for each blob
float r1 =(dot(p-move1,p-move1))*8.0;
float r2 =(dot(p+move2,p+move2))*16.0;
//sum the meatballs // uh..typo maybe Oo?
float metaball =(1.0/r1+1.0/r2);
//alter the cut-off power
float col = pow(metaball,8.0);
//set the output color
return float4(col,col,col,1.0);
}
ENDCG
}
}
FallBack "VertexLit"
}
Related Posts
10 Comments + Add Comment
Leave a comment to Neke
Recent posts
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
- [LudumDare57] Theme: Depths
- MotionVector Effect: Object “disappears” when paused
Recent Comments
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by












How can I make it work?
All I see is a black sphere 🙁
Thanks!!
added some instructions, havent tested it on a sphere..but on a plane it seems to work.
Thanks for the info and for the blog.
I thought it was a material to use in several near spheres in order to achive the 2D metablob effect ^_^U
how i can remove screen position dependency?
replace line:
float4 fragPos : COLOR1;
with:
float4 uv : TEXCOORD0;
replace line:
o.fragPos = o.pos;
with:
o.uv = float4( v.texcoord.xy, 0, 0 );
replace line:
float2 p = -1.0 + 2.0 * i.fragPos.xy / float2 (7,7);
with:
float2 p = i.uv.xy-float2(0.5,0.5);
(you might have to adjust those 0.5 values, but for the same scene, it should display the blobs on middle of the plane then)
Hi, just a quick question – does this shader require Unity Pro? 🙁 Can’t get it to work so i guess it does, but want to be shure. Thanks
Doesn’t need pro, if you set the scene plane & camera to those locations, it should work..
Does it show just black or that pink/magenta color?
Only black plane (everything was done as written above, no idea what could be wrong). Could you maybe upload a project folder where it works for you?
// also tried the modifications written above (screen position dependency), everythings still the same
/* sorry, forgot to click Reply :-X */
^ Added example scene download.