daily pastebin goal
36%
SHARE
TWEET

Demo 14 - Misc with grab pass

tonynogo Jul 6th, 2017 1,575 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Grab pass" {
  2.     Properties {
  3.         _ZoomVal ("Zoom value", Range(0, 20)) = 0
  4.     }
  5.     SubShader {
  6.         GrabPass { "_GrabTexture" }
  7.  
  8.         Pass {
  9.             Tags { "Queue"="Transparent" }
  10.        
  11.             CGPROGRAM
  12.             #pragma vertex vert
  13.             #pragma fragment frag
  14.             #include "UnityCG.cginc"
  15.  
  16.             struct v2f {
  17.                 half4 pos : SV_POSITION;
  18.                 half4 grabPos : TEXCOORD0;
  19.             };
  20.  
  21.             sampler2D _GrabTexture;
  22.             half _ZoomVal;
  23.  
  24.             v2f vert(appdata_base v) {
  25.                 v2f o;
  26.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  27.                 o.grabPos = ComputeGrabScreenPos(o.pos + half4(0, 0, 0, _ZoomVal));
  28.                 return o;
  29.             }
  30.  
  31.             half4 frag(v2f i) : COLOR {
  32.                 fixed4 color = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(i.grabPos));
  33.                 fixed val = (color.x  + color.y + color.z) / 3;
  34.                 return fixed4(val, val, val, color.a);
  35.             }
  36.             ENDCG
  37.         }
  38.     }
  39.     FallBack "Diffuse"
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top