BlendHDR.shader 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Portals/BlendHDR" {
  3. Properties {
  4. [HDR]_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  5. _MainTex ("Particle Texture", 2D) = "white" {}
  6. _POW ("Texture POW scale", Float) = 1.0
  7. _InvFade ("Soft Particles Factor", Float) = 1.0
  8. }
  9. Category {
  10. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  11. Blend SrcAlpha OneMinusSrcAlpha
  12. ColorMask RGB
  13. Cull Off Lighting Off ZWrite Off
  14. SubShader {
  15. Pass {
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #pragma multi_compile_particles
  20. #pragma multi_compile_fog
  21. #include "UnityCG.cginc"
  22. sampler2D _MainTex;
  23. fixed4 _TintColor;
  24. float _POW;
  25. struct appdata_t {
  26. float4 vertex : POSITION;
  27. fixed4 color : COLOR;
  28. float2 texcoord : TEXCOORD0;
  29. };
  30. struct v2f {
  31. float4 vertex : SV_POSITION;
  32. fixed4 color : COLOR;
  33. float2 texcoord : TEXCOORD0;
  34. UNITY_FOG_COORDS(1)
  35. #ifdef SOFTPARTICLES_ON
  36. float4 projPos : TEXCOORD2;
  37. #endif
  38. };
  39. float4 _MainTex_ST;
  40. v2f vert (appdata_t v)
  41. {
  42. v2f o;
  43. o.vertex = UnityObjectToClipPos(v.vertex);
  44. #ifdef SOFTPARTICLES_ON
  45. o.projPos = ComputeScreenPos (o.vertex);
  46. COMPUTE_EYEDEPTH(o.projPos.z);
  47. #endif
  48. o.color = v.color;
  49. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  50. UNITY_TRANSFER_FOG(o,o.vertex);
  51. return o;
  52. }
  53. sampler2D_float _CameraDepthTexture;
  54. float _InvFade;
  55. float4 frag (v2f i) : SV_Target
  56. {
  57. #ifdef SOFTPARTICLES_ON
  58. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  59. float partZ = i.projPos.z;
  60. float fade = saturate (_InvFade * (sceneZ-partZ));
  61. i.color.a *= fade;
  62. #endif
  63. float4 tex = tex2D(_MainTex, i.texcoord);
  64. tex = pow(tex,_POW);
  65. float4 col = 2.0f * i.color * _TintColor * tex;
  66. UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
  67. col.a = saturate(col.a);
  68. return col;
  69. }
  70. ENDCG
  71. }
  72. }
  73. }
  74. }