Advertisement
tonynogo

Demo 52 - Checkerboard

Jul 6th, 2017
3,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/PostRenderingCheckerboard"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _Color ("Color", color) = (1, 1, 1, 1)
  7.         [PowerSlider(2.0)] _Val ("Size", Range(0.0, 1)) = 0
  8.     }
  9.  
  10.     SubShader
  11.     {
  12.         Pass
  13.         {
  14.             CGPROGRAM
  15.             #pragma vertex vert_img
  16.             #pragma fragment frag
  17.             #include "UnityCG.cginc"
  18.  
  19.             sampler2D _MainTex;
  20.             fixed4 _Color;
  21.             half _Val;
  22.  
  23.             fixed4 frag(v2f_img i) : SV_Target {
  24.                 float2 val = floor(i.pos.xy * _Val) * 0.5;
  25.  
  26.                 if(frac(val.x + val.y) > 0)
  27.                     return _Color;
  28.  
  29.                 return tex2D(_MainTex, i.uv);
  30.             }
  31.  
  32.             ENDCG
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement