SeparableBlur.shader 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Hidden/SeparableBlur" {
  3. Properties {
  4. _MainTex ("Base (RGB)", 2D) = "" {}
  5. }
  6. CGINCLUDE
  7. #include "UnityCG.cginc"
  8. struct v2f {
  9. float4 pos : SV_POSITION;
  10. float2 uv : TEXCOORD0;
  11. float4 uv01 : TEXCOORD1;
  12. float4 uv23 : TEXCOORD2;
  13. float4 uv45 : TEXCOORD3;
  14. };
  15. float4 offsets;
  16. sampler2D _MainTex;
  17. v2f vert (appdata_img v) {
  18. v2f o;
  19. o.pos = UnityObjectToClipPos(v.vertex);
  20. o.uv.xy = v.texcoord.xy;
  21. o.uv01 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1);
  22. o.uv23 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 2.0;
  23. o.uv45 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 3.0;
  24. return o;
  25. }
  26. half4 frag (v2f i) : SV_Target {
  27. half4 color = float4 (0,0,0,0);
  28. color += 0.40 * tex2D (_MainTex, i.uv);
  29. color += 0.15 * tex2D (_MainTex, i.uv01.xy);
  30. color += 0.15 * tex2D (_MainTex, i.uv01.zw);
  31. color += 0.10 * tex2D (_MainTex, i.uv23.xy);
  32. color += 0.10 * tex2D (_MainTex, i.uv23.zw);
  33. color += 0.05 * tex2D (_MainTex, i.uv45.xy);
  34. color += 0.05 * tex2D (_MainTex, i.uv45.zw);
  35. return color;
  36. }
  37. ENDCG
  38. Subshader {
  39. Pass {
  40. ZTest Always Cull Off ZWrite Off
  41. CGPROGRAM
  42. #pragma vertex vert
  43. #pragma fragment frag
  44. ENDCG
  45. }
  46. }
  47. Fallback off
  48. } // shader