SeparableBlur.shader 1.7 KB

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