Created
June 14, 2013 23:26
-
-
Save bzgeb/5786053 to your computer and use it in GitHub Desktop.
Accidental anaglyph 3d shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Hidden/Anaglyph Effect" { | |
Properties { | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
} | |
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 _TexWidth; | |
uniform float _TexHeight; | |
fixed4 frag (v2f_img i) : COLOR | |
{ | |
float uvPixelWidth = 1 / _TexWidth; | |
float uvPixelHeight = 1 / _TexHeight; | |
fixed4 original = tex2D(_MainTex, i.uv); | |
for ( int h = -4; h < 4; ++h ) { | |
for ( int j = -4; j < 4; ++j ) { | |
fixed4 neighbour = tex2D( _MainTex, i.uv + (h * uvPixelWidth) + (j * uvPixelHeight) ); | |
original.gb = neighbour.r; | |
} | |
} | |
return original; | |
} | |
ENDCG | |
} | |
} | |
Fallback off | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment