Skip to content

Instantly share code, notes, and snippets.

@nevarman
Created January 15, 2016 12:23
Show Gist options
  • Save nevarman/955ddc254cc8ec854b16 to your computer and use it in GitHub Desktop.
Save nevarman/955ddc254cc8ec854b16 to your computer and use it in GitHub Desktop.
Splat effect shader like painting spill
Shader "Special/Splat"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_NoiseTex ("Texture", 2D) = "white" {}
_Warp ("Warp", Range(0,1)) = 0
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType" = "Plane"
}
Cull Off
Lighting Off
ZWrite Off
Fog{ Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
float2 world : TEXCOORD1;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.color;
o.uv = v.uv;
o.world = mul(_Object2World, v.vertex).xy;
return o;
}
sampler2D _MainTex;
sampler2D _NoiseTex;
float _Warp;
fixed4 frag (v2f i) : SV_Target
{
fixed2 warp = (((tex2D(_NoiseTex, i.world).rg) * 2) - 1) * _Warp;
fixed4 col = tex2D(_MainTex, i.uv + warp);
col *= i.color;
return col;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment