Advertisement
Guest User

Pallette Cycle Shader

a guest
Apr 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. Shader "Palette Cycle" {
  2. Properties{
  3. _Color("Base Color", Color) = (1,1,1,1)
  4. _EmissiveColor("Emissive Color", Color) = (1,1,1,1)
  5. [Toggle]_EmissiveOnly("Show Emissive Only", Float) = 0
  6. _MainTex("Albedo (RGB)", 2D) = "white" {}
  7. _NormalMap("Normal Map", 2D) = "bump" {}
  8. _IntensityMap("Intensity Map", 2D) = "none" {}
  9. _CycleGuide("Cycle Guide", 2D) = "none" {}
  10. _AlphaMap("Alpha Map", 2D) = "white" {}
  11. _EmissiveAmp("Emissive Multiplier", Range(1,99)) = 1
  12. _TimeMult("Time Multiplier", Range(0.1, 2)) = 1
  13. _Fade("Fade", Range(0.1, 0.99)) = 0.5
  14. _IXShift("Inten. X Slide Speed", Range(-3, 3)) = 0
  15. _IYShift("Inten. Y Slide Speed", Range(-3, 3)) = 0
  16. _CXShift("Cycle. X Slide Speed", Range(-3, 3)) = 0
  17. _CYShift("Cycle. Y Slide Speed", Range(-3, 3)) = 0
  18. _Metallic("Metallic", Range(0,1)) = 0
  19. _Smoothness("Smoothness", Range(0,1)) = 0
  20. [Enum(Off, 0, Front, 1, Back , 2)] _Cull ("Cull", Int) = 1
  21. }
  22. SubShader{
  23. Tags
  24. {
  25. "Queue" = "Transparent"
  26. "RenderType" = "Transparent"
  27. "IgnoreProjector" = "True"
  28. }
  29. //Blend SrcAlpha OneMinusSarcAlpha
  30. Cull [_Cull]
  31. LOD 200
  32. CGPROGRAM
  33. // Physically based Standard lighting model, and enable shadows on all light types
  34. #pragma surface surf Standard fullforwardshadows alpha:fade
  35.  
  36. // Use shader model 3.0 target, to get nicer looking lighting
  37. #pragma target 3.0
  38.  
  39. sampler2D _MainTex;
  40. sampler2D _CycleGuide;
  41. sampler2D _NormalMap;
  42. sampler2D _AlphaMap;
  43. sampler2D _IntensityMap;
  44.  
  45. struct Input
  46. {
  47. float2 uv_MainTex;
  48. float2 uv_CycleGuide;
  49. float2 uv_NormalMap;
  50. float2 uv_AlphaMap;
  51. float2 uv_IntensityMap;
  52. };
  53.  
  54. half _Metallic;
  55. half _Smoothness;
  56. float _Fade;
  57. float _TimeMult;
  58. float _IYShift;
  59. float _IXShift;
  60. float _CYShift;
  61. float _CXShift;
  62. fixed4 _Color;
  63. fixed4 _EmissiveColor;
  64. float _EmissiveAmp;
  65. bool _EmissiveOnly;
  66.  
  67.  
  68. void surf(Input IN, inout SurfaceOutputStandard o)
  69. {
  70. //Incriment the UVValues by time.
  71. IN.uv_IntensityMap.x += sin(_Time * _TimeMult * _IXShift);
  72. IN.uv_IntensityMap.y += sin(_Time * _TimeMult * _IYShift);
  73. IN.uv_CycleGuide.x += sin(_Time * _TimeMult * _CXShift);
  74. IN.uv_CycleGuide.y += sin(_Time * _TimeMult * _CYShift);
  75.  
  76. // Metallic and Smoothness
  77. o.Metallic = _Metallic;
  78. o.Smoothness = _Smoothness;
  79.  
  80. // Albedo comes from a texture tinted by color
  81. fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  82. fixed4 e = tex2D(_CycleGuide, IN.uv_CycleGuide);
  83. o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_NormalMap));
  84. o.Alpha = tex2D(_AlphaMap, IN.uv_AlphaMap) * _Color.a;
  85.  
  86. half4 intense = tex2D(_IntensityMap, IN.uv_IntensityMap);
  87. o.Albedo = c.rgb;
  88. if (e.a > 0.01)
  89. {
  90. e.r = (fmod(e.r + _Time.y * _TimeMult + intense.r, 1));
  91. e.b = (fmod(e.b + _Time.y * _TimeMult + intense.b, 1));
  92. e.g = (fmod(e.g + _Time.y * _TimeMult + intense.g, 1));
  93. o.Emission = ((saturate(e.rgb - _Fade) * _EmissiveColor) * _EmissiveAmp);
  94. }
  95.  
  96.  
  97. if (_EmissiveOnly)
  98. {
  99. o.Alpha = tex2D(_AlphaMap, IN.uv_AlphaMap);
  100. if ((o.Emission.r == 0) && (o.Emission.b == 0) && (o.Emission.g == 0))
  101. {
  102. clip(-1);
  103. }
  104. }
  105. }
  106. ENDCG
  107. }
  108. FallBack "Diffuse"
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement