Glow.shader 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Max820/Glow" {
  3. Properties {
  4. _MainTex ("Base Texture", 2D) = "white" {}
  5. _Color("Color", Color) = (1,1,1,1)
  6. _Multiplier("Color Multiplier", float) = 1
  7. _Bias("Bias",float) = 0
  8. _TimeOnDuration("ON Duration",float) = 0.5
  9. _TimeOffDuration("OFF Duration",float) = 0.5
  10. _BlinkingTimeOffsScale("Blinking Time",float) = 5
  11. _NoiseAmount("Noise Amount", Range(0,1)) = 0
  12. }
  13. SubShader {
  14. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  15. Blend One One
  16. // Blend One OneMinusSrcColor
  17. Cull Off
  18. Lighting Off
  19. ZWrite Off
  20. Fog { Color (0,0,0,0) }
  21. LOD 100
  22. CGINCLUDE
  23. #include "UnityCG.cginc"
  24. sampler2D _MainTex;
  25. float4 _Color;
  26. float _Multiplier;
  27. float _Bias;
  28. float _TimeOnDuration;
  29. float _TimeOffDuration;
  30. float _BlinkingTimeOffsScale;
  31. float _NoiseAmount;
  32. struct v2f {
  33. float4 pos : SV_POSITION;
  34. float2 uv : TEXCOORD0;
  35. fixed4 color : TEXCOORD1;
  36. };
  37. v2f vert (appdata_full v)
  38. {
  39. v2f o;
  40. float time = _Time.y + _BlinkingTimeOffsScale * v.color.b;
  41. float fracTime = fmod(time,_TimeOnDuration + _TimeOffDuration);
  42. float wave = smoothstep(0,_TimeOnDuration * 0.25,fracTime) * (1 - smoothstep(_TimeOnDuration * 0.75,_TimeOnDuration,fracTime));
  43. float noiseTime = time * (6.2831853f / _TimeOnDuration);
  44. float noise = sin(noiseTime) * (0.5f * cos(noiseTime * 0.6366f + 56.7272f) + 0.5f);
  45. float noiseWave = _NoiseAmount * noise + (1 - _NoiseAmount);
  46. wave = _NoiseAmount < 0.01f ? wave : noiseWave;
  47. wave += _Bias;
  48. float4 mdlPos = v.vertex;
  49. o.uv = v.texcoord.xy;
  50. o.pos = UnityObjectToClipPos(mdlPos);
  51. o.color = _Color * _Multiplier * wave;
  52. return o;
  53. }
  54. ENDCG
  55. Pass {
  56. CGPROGRAM
  57. #pragma vertex vert
  58. #pragma fragment frag
  59. #pragma fragmentoption ARB_precision_hint_fastest
  60. fixed4 frag (v2f i) : COLOR
  61. {
  62. return tex2D (_MainTex, i.uv.xy) * i.color;
  63. }
  64. ENDCG
  65. }
  66. }
  67. }