PatchQuest

ParticleRamp Shader

Sep 13th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1.  
  2. Shader "Custom/Particles/Ramp" {
  3. Properties{
  4. _MainTex("Particle Texture", 2D) = "white" {}
  5. _RampBlack("Ramp Black", Color) = (0, 0, 0, 1)
  6. _RampWhite("Ramp White", Color) = (1, 1, 1, 1)
  7. }
  8.  
  9. Category{
  10. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  11. Blend SrcAlpha OneMinusSrcAlpha
  12. AlphaTest Greater .01
  13. ColorMask RGB
  14. Cull Off Lighting Off ZWrite Off Fog{ Color(0,0,0,0) }
  15. BindChannels{
  16. Bind "Color", color
  17. Bind "Vertex", vertex
  18. Bind "TexCoord", texcoord
  19. }
  20.  
  21. SubShader{
  22.  
  23. Pass{
  24.  
  25. CGPROGRAM
  26. #pragma vertex vert
  27. #pragma fragment frag
  28. #pragma fragmentoption ARB_precision_hint_fastest
  29. #pragma fragmentoption ARB_fog_exp2
  30.  
  31. #include "UnityCG.cginc"
  32.  
  33. sampler2D _MainTex;
  34. float4 _RampBlack;
  35. float4 _RampWhite;
  36.  
  37. struct appdata_t {
  38. float4 vertex : POSITION;
  39. float4 color : COLOR;
  40. float2 texcoord : TEXCOORD0;
  41. };
  42.  
  43. struct v2f {
  44. float4 vertex : POSITION;
  45. float4 color : COLOR;
  46. float2 texcoord : TEXCOORD0;
  47. };
  48.  
  49. float4 _MainTex_ST;
  50.  
  51. v2f vert(appdata_t v)
  52. {
  53. v2f o;
  54. o.vertex = UnityObjectToClipPos(v.vertex);
  55. o.color = v.color;
  56. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  57. return o;
  58. }
  59.  
  60. half4 frag(v2f i) : COLOR
  61. {
  62. float4 color = i.color * tex2D(_MainTex, i.texcoord);
  63. float grayscale = (color.r + color.g + color.b) / 3;
  64.  
  65. float lerpR = _RampBlack.r + (_RampWhite.r - _RampBlack.r) * grayscale;
  66. float lerpG = _RampBlack.g + (_RampWhite.g - _RampBlack.g) * grayscale;
  67. float lerpB = _RampBlack.b + (_RampWhite.b - _RampBlack.b) * grayscale;
  68.  
  69. return half4 (lerpR, lerpG, lerpB, color.a);
  70. }
  71. ENDCG
  72. }
  73. }
  74.  
  75. }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment