Advertisement
Guest User

glitch

a guest
Aug 28th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. Shader "GUI/Glitch"
  4. {
  5.     Properties
  6.     {
  7.         _MainTex ("Base (RGB)", 2D) = "white" {}
  8.     }
  9.  
  10.     SubShader
  11.     {
  12.        
  13.         Pass
  14.         {
  15.                 Ztest off Cull Off ZWrite Off Fog { Mode off }
  16.                
  17.                 CGPROGRAM
  18.                 #pragma vertex vert_img
  19.                 #pragma fragment frag
  20.                 #pragma fragmentoption ARB_precision_hint_fastest
  21.                 #include "UnityCG.cginc"
  22.                
  23.  
  24.                 uniform sampler2D _MainTex;
  25.                 uniform float3 _Stats;
  26.  
  27.                 inline float rand(float2 seed)
  28.                 {
  29.                     return frac(sin(dot(seed * floor(_Time * _Stats.x), float2(127.1, 311.7))) * 1.123456);
  30.                    
  31.                 }
  32.  
  33.                 struct v2f {
  34.                     float4 pos : POSITION;
  35.                     float2 uv : TEXCOORD0;
  36.                 };
  37.        
  38.                 v2f vert( appdata_img v )
  39.                 {
  40.                     v2f o;
  41.                     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
  42.                     o.uv = v.texcoord.xy;
  43.            
  44.                     return o;
  45.                 }              
  46.                
  47.                
  48.                 half4 frag(v2f i) : COLOR
  49.                  {
  50.                     float2 rblock = rand(floor(i.uv * _Stats.y));
  51.                     float displaceNoise = pow(rblock.x, 8.0) * pow(rblock.x, 3.0) - pow(rand(7.2341), 17.0) * _Stats.z;
  52.                    
  53.                     float r = tex2D(_MainTex, i.uv).r;
  54.                     float b = tex2D(_MainTex, i.uv - half2(displaceNoise * 0.05 * rand(13.0), 0.0)).b;
  55.                     float g = tex2D(_MainTex, i.uv - half2(displaceNoise * 0.05 * rand(13.0), 0.0)).g;
  56.  
  57.                    
  58.                     half4 color = tex2D(_MainTex,  i.uv.xy);
  59.            
  60.                    
  61.                         color.r = r*1.2;
  62.                         color.g = g;
  63.                         color.b = b;
  64.                                        
  65.                    
  66.                     return color;
  67.                  
  68.               }
  69.  
  70.             ENDCG
  71.         }
  72.  
  73.  
  74.     }
  75.  
  76.     FallBack off
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement