
ChromaticAberration
By:
boofcw on
May 2nd, 2012 | syntax:
C | size: 1.39 KB | hits: 51 | expires: Never
Shader "Hidden/ChromaticAberration"
{
Properties
{
_MainTex ( "Base (RGB)" , 2D ) = "white" {}
_Scale ( "Scale" , Float ) = 1.0
_ColorDelta ( "Scale" , Float ) = 0.05
_CalculateFromCenter ( "Scale" , Float ) = 1
_Falloff ( "_Falloff" , Float ) = 1
_FalloffBuffer ( "_Falloff" , Float ) = 0
}
SubShader
{
Pass
{
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float _Scale;
uniform float _ColorDelta;
uniform float _CalculateFromCenter;
uniform float _Falloff;
uniform float _FalloffBuffer;
fixed4 frag ( v2f_img i ) : COLOR
{
half4 c;
float dist = 1;
if( _CalculateFromCenter == 1 )
{
float2 vec = i.uv - ( 0.5 , 0.5 );
dist = length( vec );
}
dist -= _FalloffBuffer;
if( dist < 0 ) dist = 0;
dist *= _Falloff;
half2 uvR = ( i.uv + 0.0007 * _Scale * dist );
half2 uvB = ( i.uv - 0.0007 * _Scale * dist );
c.r = tex2D( _MainTex , uvR ).r * 1 + _ColorDelta * dist;
c.ga = tex2D( _MainTex , i.uv ).ga;
c.b = tex2D( _MainTex , uvB ).b * 1 - _ColorDelta * dist;
return c;
}
ENDCG
}
}
Fallback off
}