SeparableBlurPlus.shader 1.6 KB

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