SingleLine-LightSaber.shader 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /// Render a single volumetric line using an additive shader which does not support changing the color
  2. ///
  3. /// Based on the Volumetric lines algorithm by Sebastien Hillaire
  4. /// http://sebastien.hillaire.free.fr/index.php?option=com_content&view=article&id=57&Itemid=74
  5. ///
  6. /// Thread in the Unity3D Forum:
  7. /// http://forum.unity3d.com/threads/181618-Volumetric-lines
  8. ///
  9. /// Unity3D port by Johannes Unterguggenberger
  10. /// johannes.unterguggenberger@gmail.com
  11. ///
  12. /// Thanks to Michael Probst for support during development.
  13. ///
  14. /// Thanks for bugfixes and improvements to Unity Forum User "Mistale"
  15. /// http://forum.unity3d.com/members/102350-Mistale
  16. ///
  17. /// Shader code optimization and cleanup by Lex Darlog (aka DRL)
  18. /// http://forum.unity3d.com/members/lex-drl.67487/
  19. ///
  20. /// Single Pass Stereo Support by Unity Forum User "Abnormalia_"
  21. /// https://forum.unity.com/members/abnormalia_.356336/
  22. ///
  23. /// Single pass instanced rendering fix by Niel
  24. ///
  25. Shader "VolumetricLine/SingleLine-LightSaber" {
  26. Properties {
  27. [NoScaleOffset] _MainTex ("Base (RGB)", 2D) = "white" {}
  28. _LineWidth ("Line Width", Range(0.01, 100)) = 1.0
  29. _LineScale ("Line Scale", Float) = 1.0
  30. _LightSaberFactor ("LightSaberFactor", Range(0.0, 1.0)) = 0.9
  31. [MaterialToggle] _UvBasedLightSaberFactor("UV-Based Light Saber Calculation (Anti-Aliased)", Int) = 0
  32. _Color ("Main Color", Color) = (1,1,1,1)
  33. }
  34. SubShader {
  35. // batching is forcefully disabled here because the shader simply won't work with it:
  36. Tags {
  37. "DisableBatching"="True"
  38. "RenderType"="Transparent"
  39. "Queue"="Transparent"
  40. "IgnoreProjector"="True"
  41. "ForceNoShadowCasting"="True"
  42. "PreviewType"="Plane"
  43. }
  44. LOD 200
  45. Pass {
  46. Cull Off
  47. ZWrite Off
  48. ZTest LEqual
  49. Blend One One
  50. Lighting Off
  51. CGPROGRAM
  52. #pragma glsl_no_auto_normalization
  53. #pragma vertex vert
  54. #pragma fragment frag
  55. // tell the cginc file that this is a simplified version of the shader:
  56. #define LIGHT_SABER_MODE_ON
  57. #include "_SingleLineShader.cginc"
  58. ENDCG
  59. }
  60. }
  61. FallBack "Diffuse"
  62. }