Guest User

Untitled

a guest
Jul 3rd, 2018
157
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Nova/VerticalFogAnimated"
  2. {
  3. Properties
  4. {
  5. _Color("Main Color", Color) = (1, 1, 1, .5)
  6. _IntersectionThresholdMax("Intersection Threshold Max", float) = 1
  7. _AlphaMask("Alpha Mask", 2D) = "white" {}
  8. // variable_name("name in inspector", variable_type) = initial_value
  9. _HorizontalSpeed("Horizontal Speed", Float) = 1
  10. _VerticalSpeed("Vertical Speed", Float) = 0
  11. }
  12. SubShader
  13. {
  14. Tags { "Queue" = "Transparent" "RenderType"="Transparent" }
  15.  
  16. Pass
  17. {
  18. Blend SrcAlpha OneMinusSrcAlpha
  19. ZWrite Off
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23. #pragma multi_compile_fog
  24. #include "UnityCG.cginc"
  25.  
  26. struct appdata
  27. {
  28. float4 vertex : POSITION;
  29. half4 uv : TEXCOORD0;
  30. };
  31.  
  32. struct v2f
  33. {
  34. half4 uv : TEXCOORD0;
  35. float4 scrPos : TEXCOORD1;
  36. UNITY_FOG_COORDS(1)
  37. float4 vertex : SV_POSITION;
  38. };
  39.  
  40. sampler2D _CameraDepthTexture, _AlphaMask;
  41. float4 _Color;
  42. float _IntersectionThresholdMax;
  43.  
  44. // here we declare variables inside CG program
  45. half _HorizontalSpeed, _VerticalSpeed;
  46.  
  47. v2f vert(appdata v)
  48. {
  49. v2f o;
  50. o.vertex = UnityObjectToClipPos(v.vertex);
  51. o.scrPos = ComputeScreenPos(o.vertex);
  52. o.uv = v.uv;
  53. UNITY_TRANSFER_FOG(o,o.vertex);
  54. return o;
  55. }
  56.  
  57.  
  58. fixed GetAlphaMult(half4 uv0, sampler2D alphamask)
  59. {
  60. fixed mainMask = 1 - tex2D(alphamask, uv0.xy).g;
  61.  
  62. float time = _Time.x;
  63. uv0.x += frac(time * _HorizontalSpeed);
  64. uv0.y += frac(time * _VerticalSpeed);
  65.  
  66. fixed animationMask = 1 - tex2D(alphamask, uv0.xy).r;
  67.  
  68. return mainMask * animationMask;
  69. }
  70.  
  71.  
  72. half4 frag(v2f i) : SV_TARGET
  73. {
  74. float depth = LinearEyeDepth (tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.scrPos)));
  75. float diff = saturate(_IntersectionThresholdMax * (depth - i.scrPos.w));
  76.  
  77. fixed4 col = lerp(fixed4(_Color.rgb, 0.0), _Color, diff * diff * diff * (diff * (6 * diff - 15) + 10));
  78. col.a *= GetAlphaMult(i.uv, _AlphaMask);
  79.  
  80. UNITY_APPLY_FOG(i.fogCoord, col);
  81. return col;
  82. }
  83.  
  84. ENDCG
  85. }
  86. }
  87. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×