MotionBlur.shader 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Hidden/MotionBlur" {
  3. Properties {
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. _AccumOrig("AccumOrig", Float) = 0.65
  6. }
  7. SubShader {
  8. ZTest Always Cull Off ZWrite Off
  9. Fog { Mode off }
  10. Pass {
  11. Blend SrcAlpha OneMinusSrcAlpha
  12. ColorMask RGB
  13. BindChannels {
  14. Bind "vertex", vertex
  15. Bind "texcoord", texcoord
  16. }
  17. CGPROGRAM
  18. #pragma vertex vert
  19. #pragma fragment frag
  20. #pragma fragmentoption ARB_precision_hint_fastest
  21. #include "UnityCG.cginc"
  22. struct appdata_t {
  23. float4 vertex : POSITION;
  24. float2 texcoord : TEXCOORD;
  25. };
  26. struct v2f {
  27. float4 vertex : POSITION;
  28. float2 texcoord : TEXCOORD;
  29. };
  30. float4 _MainTex_ST;
  31. float _AccumOrig;
  32. v2f vert (appdata_t v)
  33. {
  34. v2f o;
  35. o.vertex = UnityObjectToClipPos(v.vertex);
  36. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  37. return o;
  38. }
  39. sampler2D _MainTex;
  40. half4 frag (v2f i) : COLOR
  41. {
  42. return half4(tex2D(_MainTex, i.texcoord).rgb, _AccumOrig );
  43. }
  44. ENDCG
  45. }
  46. Pass {
  47. Blend One Zero
  48. ColorMask A
  49. BindChannels {
  50. Bind "vertex", vertex
  51. Bind "texcoord", texcoord
  52. }
  53. CGPROGRAM
  54. #pragma vertex vert
  55. #pragma fragment frag
  56. #pragma fragmentoption ARB_precision_hint_fastest
  57. #include "UnityCG.cginc"
  58. struct appdata_t {
  59. float4 vertex : POSITION;
  60. float2 texcoord : TEXCOORD;
  61. };
  62. struct v2f {
  63. float4 vertex : POSITION;
  64. float2 texcoord : TEXCOORD;
  65. };
  66. float4 _MainTex_ST;
  67. v2f vert (appdata_t v)
  68. {
  69. v2f o;
  70. o.vertex = UnityObjectToClipPos(v.vertex);
  71. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  72. return o;
  73. }
  74. sampler2D _MainTex;
  75. half4 frag (v2f i) : COLOR
  76. {
  77. return tex2D(_MainTex, i.texcoord);
  78. }
  79. ENDCG
  80. }
  81. }
  82. SubShader {
  83. ZTest Always Cull Off ZWrite Off
  84. Fog { Mode off }
  85. Pass {
  86. Blend SrcAlpha OneMinusSrcAlpha
  87. ColorMask RGB
  88. SetTexture [_MainTex] {
  89. ConstantColor (0,0,0,[_AccumOrig])
  90. Combine texture, constant
  91. }
  92. }
  93. Pass {
  94. Blend One Zero
  95. ColorMask A
  96. SetTexture [_MainTex] {
  97. Combine texture
  98. }
  99. }
  100. }
  101. Fallback off
  102. }