LightCone.shader 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "FX/LightCone" {
  3. Properties{
  4. _TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
  5. _InvFade("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  6. _Rim ("rim power", Range(0,10)) = 1.0
  7. }
  8. Category{
  9. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  10. Blend SrcAlpha One
  11. ColorMask RGB
  12. Cull Off Lighting Off ZWrite Off Fog{ Color(0,0,0,0) }
  13. ZTest Off
  14. SubShader{
  15. Pass{
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #pragma multi_compile_particles
  20. #include "UnityCG.cginc"
  21. sampler2D _MainTex;
  22. fixed4 _TintColor;
  23. uniform fixed _BWEffectOn;
  24. struct appdata_t {
  25. float4 vertex : POSITION;
  26. float3 normal : NORMAL;
  27. fixed4 color : COLOR;
  28. fixed4 viewDir : TEXCOORD0;
  29. };
  30. struct v2f {
  31. float4 vertex : SV_POSITION;
  32. fixed4 color : COLOR;
  33. #ifdef SOFTPARTICLES_ON
  34. float4 projPos : TEXCOORD0;
  35. #endif
  36. float3 normal : NORMAL;
  37. float3 viewDir : TEXCOORD1;
  38. };
  39. v2f vert(appdata_t v)
  40. {
  41. v2f o;
  42. o.vertex = UnityObjectToClipPos(v.vertex);
  43. #ifdef SOFTPARTICLES_ON
  44. o.projPos = ComputeScreenPos(o.vertex);
  45. COMPUTE_EYEDEPTH(o.projPos.z);
  46. #endif
  47. o.color = v.color;
  48. o.normal = v.normal;
  49. o.viewDir = normalize(ObjSpaceViewDir(v.vertex));
  50. return o;
  51. }
  52. sampler2D_float _CameraDepthTexture;
  53. float _InvFade;
  54. half _Rim;
  55. fixed4 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 = 1 - saturate(_InvFade * (partZ - sceneZ));
  61. i.color.a *= fade;
  62. #endif
  63. i.color = pow(i.color,3);
  64. half rim = saturate(pow(saturate(abs(dot(i.viewDir, i.normal))),_Rim));
  65. i.color.a *= rim;
  66. fixed4 finalCol = 2.0f * i.color * _TintColor;
  67. fixed lum = Luminance(finalCol.xyz);
  68. return finalCol;
  69. }
  70. ENDCG
  71. }
  72. }
  73. }
  74. }