Guest User

Untitled

a guest
Jun 25th, 2018
832
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/FogProjection"
  2. {
  3. Properties
  4. {
  5. _PrevTexture ("Previous Texture", 2D) = "white" {}
  6. _CurrTexture ("Current Texture", 2D) = "white" {}
  7. _Color ("Color", Color) = (0, 0, 0, 0)
  8. _Blend("Blend", Float) = 0
  9. }
  10. SubShader
  11. {
  12. Tags { "Queue"="Transparent+100" } // to cover other transparent non-z-write things
  13.  
  14. Pass
  15. {
  16. ZWrite Off
  17. Blend SrcAlpha OneMinusSrcAlpha
  18. ZTest Equal
  19.  
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23.  
  24. #include "UnityCG.cginc"
  25.  
  26. struct appdata
  27. {
  28. float4 vertex : POSITION;
  29. float4 uv : TEXCOORD0;
  30. };
  31.  
  32. struct v2f
  33. {
  34. float4 uv : TEXCOORD0;
  35. float4 vertex : SV_POSITION;
  36. };
  37.  
  38.  
  39. float4x4 unity_Projector;
  40. sampler2D _CurrTexture;
  41. sampler2D _PrevTexture;
  42. fixed4 _Color;
  43. float _Blend;
  44.  
  45. v2f vert (appdata v)
  46. {
  47. v2f o;
  48. o.vertex = UnityObjectToClipPos(v.vertex);
  49. o.uv = mul(unity_Projector, v.vertex);
  50. return o;
  51. }
  52.  
  53. fixed4 frag (v2f i) : SV_Target
  54. {
  55. float aPrev = tex2Dproj(_PrevTexture, i.uv).a;
  56. float aCurr = tex2Dproj(_CurrTexture, i.uv).a;
  57.  
  58. fixed a = lerp(aPrev, aCurr, _Blend);
  59.  
  60. // weird things happen to minimap if alpha value gets negative
  61. _Color.a = max(0, _Color.a - a);
  62. return _Color;
  63. }
  64. ENDCG
  65. }
  66. }
  67. }
RAW Paste Data