Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. Shader "Pixelate" {
  2. Properties {
  3. _CellSize ("Cell Size", Vector) = (0.02, 0.02, 0, 0)
  4. }
  5. SubShader {
  6. Tags { "RenderType"="Opaque" }
  7. LOD 200
  8.  
  9. GrabPass { "_PixelationGrabTexture"}
  10.  
  11. Pass {
  12. CGPROGRAM
  13. #pragma vertex vert
  14. #pragma fragment frag
  15. #include "UnityCG.cginc"
  16.  
  17. struct v2f {
  18. float4 pos : SV_POSITION;
  19. float4 grabUV : TEXCOORD0;
  20. };
  21.  
  22. float4 _CellSize;
  23.  
  24. v2f vert(appdata_base v) {
  25. v2f o;
  26. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  27. o.grabUV = ComputeGrabScreenPos(o.pos);
  28. return o;
  29. }
  30.  
  31. sampler2D _PixelationGrabTexture;
  32.  
  33. float4 frag(v2f IN) : COLOR {
  34. float2 steppedUV = IN.grabUV.xy/IN.grabUV.w;
  35. steppedUV /= _CellSize.xy;
  36. steppedUV = round(steppedUV);
  37. steppedUV *= _CellSize.xy;
  38. return tex2D(_PixelationGrabTexture, steppedUV);
  39. }
  40. ENDCG
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement