AllIn1SpriteShaderScrollView.shader 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  1. Shader "AllIn1SpriteShader/AllIn1SpriteShaderScrollView"
  2. {
  3. Properties
  4. {
  5. [Header(_General Properties_)]
  6. _MainTex("Main Texture", 2D) = "white" {} //0
  7. _Color("Main Color", Color) = (1,1,1,1) //1
  8. _Alpha("General Alpha", Range(0,1)) = 1 //2
  9. _GlowColor("Glow Color", Color) = (1,1,1,1) //3
  10. _Glow("Glow Intensity", Range(0,100)) = 10 //4
  11. [Space]
  12. [Space]
  13. [Toggle()] _GlowTexUsed("Glow Texture used?", float) = 0 //5
  14. [Header(Texture does not support Tiling)]
  15. _GlowTex("Glow Texture", 2D) = "white" {} //6
  16. _FadeTex("Fade Texture", 2D) = "white" {} //7
  17. _FadeAmount("Fade Amount", Range(-0.1,1)) = -0.1 //8
  18. _FadeBurnWidth("Fade Burn Width", Range(0,1)) = 0.025 //9
  19. _FadeBurnTransition("Fade Burn Smooth Transition", Range(0.01,0.5)) = 0.075 //10
  20. _FadeBurnColor("Fade Burn Color", Color) = (1,1,0,1) //11
  21. _FadeBurnTex("Fade Burn Texture", 2D) = "white" {} //12
  22. _FadeBurnGlow("Fade Burn Glow", Range(1,50)) = 2//13
  23. [Header(_Outline Basic Properties_)]
  24. _OutlineColor("Outline Base Color", Color) = (1,1,1,1) //14
  25. _OutlineAlpha("Outline Base Alpha", Range(0,1)) = 1 //15
  26. _OutlineGlow("Outline Base Glow", Range(1,100)) = 1.5 //16
  27. [Toggle()] _Outline8Directions("Outline Base High Resolution?", float) = 0 //17
  28. _OutlineWidth("Outline Base Width", Range(0,0.2)) = 0.004 //18
  29. [Header(_Outline Width_)]
  30. [Toggle()] _OutlineIsPixel("Outline Base is Pixel Perfect?", float) = 0 //19
  31. _OutlinePixelWidth("Outline Base Pixel Width", Int) = 1 //20
  32. [Space]
  33. [Header(_Outline Texture_)]
  34. [Toggle()] _OutlineTexToggle("Outline uses texture?", float) = 0 //21
  35. _OutlineTex("Outline Texture", 2D) = "white" {} //22
  36. _OutlineTexXSpeed("Outline Texture scroll speed X axis", Range(-50,50)) = 10 //23
  37. _OutlineTexYSpeed("Outline Texture scroll speed Y axis", Range(-50,50)) = 0 //24
  38. [Toggle()] _OutlineTexGrey("Outline Texture is Greyscaled?", float) = 0 //25
  39. [Space]
  40. [Header(_Outline Distortion_)]
  41. [Toggle()] _OutlineDistortToggle("Outline uses distortion?", float) = 0 //26
  42. _OutlineDistortTex("Outline Distortion Texture", 2D) = "white" {} //27
  43. _OutlineDistortAmount("Outline Distortion Amounts", Range(0,2)) = 0.5 //28
  44. _OutlineDistortTexXSpeed("Outline Distortion scroll speed X axis", Range(-50,50)) = 5 //29
  45. _OutlineDistortTexYSpeed("Outline Distortion scroll speed Y axis", Range(-50,50)) = 5 //30
  46. _GradBlend("Gradient Blend", Range(0,1)) = 1 //31
  47. _GradTopLeftCol("Gradient Top Left Color", Color) = (1,0,0,1) //32
  48. _GradTopRightCol("Gradient Top Right Color", Color) = (1,0,0,1) //33
  49. _GradBotLeftCol("Gradient Bot Left Color", Color) = (0,0,1,1) //34
  50. _GradBotRightCol("Gradient Bot Right Color", Color) = (0,0,1,1) //35
  51. _ColorSwapTex("Color Swap Texture", 2D) = "black" {} //36
  52. [Header(You will need a mask texture (see Documentation))]
  53. _ColorSwapRed("Color Swap Red Channel", Color) = (1,1,1,1) //37
  54. _ColorSwapRedLuminosity("Color Swap Red luminosity", Range(-1,1)) = 0.5 //38
  55. _ColorSwapGreen("Color Swap Green Channel", Color) = (1,1,1,1) //39
  56. _ColorSwapGreenLuminosity("Color Swap Green luminosity", Range(-1,1)) = 0.5 //40
  57. _ColorSwapBlue("Color Swap Blue Channel", Color) = (1,1,1,1) //41
  58. _ColorSwapBlueLuminosity("Color Swap Blue luminosity", Range(-1,1)) = 0.5 //42
  59. _HsvShift("Hue Shift", Range(0, 360)) = 180 //43
  60. _HsvSaturation("Hue Shift Saturation", Range(0, 2)) = 1 //44
  61. _HsvBright("Hue Shift Bright", Range(0, 2)) = 1 //45
  62. _HitEffectColor("Hit Effect Color", Color) = (1,1,1,1) //46
  63. _HitEffectGlow("Hit Effect Glow Intensity", Range(1,100)) = 5 //47
  64. [Space]
  65. [Header(_Tip_ Animate the following property)]
  66. _HitEffectBlend("Hit Effect Blend", Range(0,1)) = 1 //48
  67. _NegativeAmount("Negative Amount", Range(0, 1)) = 1 //49
  68. [Header(Looks bad with distorition effects)]
  69. _PixelateSize("Pixelate size", Range(4,512)) = 32 //50
  70. [Header(Texture does not support Tiling)]
  71. _ColorRampTex("Color ramp Texture", 2D) = "white" {} //51
  72. _ColorRampLuminosity("Color ramp luminosity", Range(-1,1)) = 0 //52
  73. [Toggle()] _ColorRampOutline("Color ramp affects outline?", float) = 0 //53
  74. _GreyscaleLuminosity("Greyscale luminosity", Range(-1,1)) = 0 //54
  75. [Toggle()] _GreyscaleOutline("Greyscale affects outline?", float) = 0 //55
  76. _GreyscaleTintColor("Greyscale Tint Color", Color) = (1,1,1,1) //56
  77. _PosterizeNumColors("Posterize Number of Colors", Range(0,100)) = 8 //57
  78. _PosterizeGamma("Posterize Amount", Range(0.1,10)) = 0.75 //58
  79. [Toggle()] _PosterizeOutline("Posterize affects outline and glow?", float) = 0 //59
  80. [Header(This effect will not affect the outline)]
  81. _BlurIntensity("Blur Intensity", Range(0,100)) = 10 //60
  82. [Toggle()] _BlurHD("Blur is Low Res?", float) = 0 //61
  83. _MotionBlurAngle("Motion Blur Angle", Range(-1, 1)) = 0.1 //62
  84. _MotionBlurDist("Motion Blur Distance", Range(-3, 3)) = 1.25 //63
  85. [Header(This effect will not affect the outline)]
  86. _GhostColorBoost("Ghost Color Boost", Range(0,5)) = 1 //64
  87. [Header(Choose the ghost color with the Main Color Property)]
  88. _GhostTransparency("Ghost Transparency", Range(0,1)) = 0 //65
  89. [Header(This effect will place the inner outlines over the original sprite)]
  90. _InnerOutlineColor("Inner Outline Color", Color) = (1,0,0,1) //66
  91. _InnerOutlineThickness("Inner Outline Thickness", Range(0,3)) = 1 //67
  92. _InnerOutlineAlpha("Inner Outline Alpha", Range(0,1)) = 1 //68
  93. _InnerOutlineGlow("Inner Outline Glow", Range(1,100)) = 1 //69
  94. _AlphaCutoffValue("Alpha cutoff value", Range(0, 1)) = 0.25 //70
  95. _HologramFlickerFreq("Hologram Flicker Frequence", Range(0, 5)) = 0.2 //71
  96. _HologramFlickerAlpha("Hologram Flicker Alpha", Range(0, 1)) = 0 //72
  97. _HologramStripesAmount("Hologram Stripes Amount", Range(0, 1)) = 0.2 //73
  98. _HologramUnmodAmount("Hologram Unchanged Amount", Range(0, 1)) = 0.4 //74
  99. _HologramStripesSpeed("Hologram Stripes Speed", Range(0, 20)) = 5 //75
  100. _HologramMinAlpha("Hologram Min Alpha", Range(0, 1)) = 0.0 //76
  101. _HologramMaxAlpha("Hologram Max Alpha", Range(0, 10)) = 1.0 //77
  102. _ChromAberrAmount("ChromAberr Amount", Range(0, 1)) = 1 //78
  103. _ChromAberrAlpha("ChromAberr Alpha", Range(0, 1)) = 0.4 //79
  104. _GlitchAmount("Glitch Amount", Range(0, 20)) = 3 //80
  105. _FlickerPercent("Flicker Percent", Range(0, 1)) = 0.05 //81
  106. _FlickerFreq("Flicker Frequency", Range(0, 5)) = 0.2 //82
  107. _FlickerAlpha("Flicker Alpha", Range(0, 1)) = 0 //83
  108. _ShadowX("Shadow X Axis", Range(-0.5, 0.5)) = 0.1 //84
  109. _ShadowY("Shadow Y Axis", Range(-0.5, 0.5)) = -0.05 //85
  110. _ShadowAlpha("Shadow Alpha", Range(0, 1)) = 0.5 //86
  111. _ShadowColor("Shadow Color", Color) = (0, 0, 0, 1) //87
  112. _HandDrawnAmount("Hand Drawn Amount", Range(2, 20)) = 10 //88
  113. _HandDrawnSpeed("Hand Drawn Speed", Range(1, 15)) = 5 //89
  114. _GrassSpeed("Grass Speed", Range(0,50)) = 2 //90
  115. _GrassWind("Grass Wind (bend amount)", Range(0,50)) = 20 //91
  116. [Space]
  117. [Toggle()] _GrassManualToggle("Grass is manually animated?", float) = 0 //92
  118. _GrassManualAnim("Grass Manual Anim", Range(-1,1)) = 1 //93
  119. _WaveAmount("Wave Amount", Range(0, 25)) = 7 //94
  120. _WaveSpeed("Wave Speed", Range(0, 25)) = 10 //95
  121. _WaveStrength("Wave Strength", Range(0, 25)) = 7.5 //96
  122. _WaveX("Wave X Axis", Range(0, 1)) = 0 //97
  123. _WaveY("Wave Y Axis", Range(0, 1)) = 0.5 //98
  124. [Header(Only on single sprites, spritesheets NOT supported)]
  125. _RectSize("Rect Size", Range(1, 4)) = 1 //99
  126. _OffsetUvX("Offset X axis", Range(-1, 1)) = 0 //100
  127. _OffsetUvY("Offset Y axis", Range(-1, 1)) = 0 //101
  128. _ClipUvLeft("Clipping Left", Range(0, 1)) = 0 //102
  129. _ClipUvRight("Clipping Right", Range(0, 1)) = 0 //103
  130. _ClipUvUp("Clipping Up", Range(0, 1)) = 0 //104
  131. _ClipUvDown("Clipping Down", Range(0, 1)) = 0 //105
  132. [Header(Set Texture Wrap Mode to Repeat)]
  133. _TextureScrollXSpeed("Texture Scroll Speed X Axis", Range(-5, 5)) = 1 //106
  134. _TextureScrollYSpeed("Texture Scroll Speed Y Axis", Range(-5, 5)) = 0 //107
  135. _ZoomUvAmount("Zoom Amount", Range(0.1, 5)) = 0.5 //108
  136. _DistortTex("Distortion Texture", 2D) = "white" {} //109
  137. _DistortAmount("Distortion Amounts", Range(0,2)) = 0.5 //110
  138. _DistortTexXSpeed("Distortion scroll speed X axis", Range(-50,50)) = 5 //111
  139. _DistortTexYSpeed("Distortion scroll speed Y axis", Range(-50,50)) = 5 //112
  140. _TwistUvAmount("Twist Amount", Range(0, 3.1416)) = 1 //113
  141. _TwistUvPosX("Twist Pos X Axis", Range(0, 1)) = 0.5 //114
  142. _TwistUvPosY("Twist Pos Y Axis", Range(0, 1)) = 0.5 //115
  143. _TwistUvRadius("Twist Radius", Range(0, 3)) = 0.75 //116
  144. [Header(_Tip_ Use Clipping effect to avoid possible undesired parts)]
  145. _RotateUvAmount("Rotate Angle (in radians)", Range(0, 6.2831)) = 0 //117
  146. _FishEyeUvAmount("Fish Eye Amount", Range(0, 0.5)) = 0.35 //118
  147. _PinchUvAmount("Pinch Amount", Range(0, 0.5)) = 0.35 //119
  148. _ShakeUvSpeed("Shake Speed", Range(0, 20)) = 2.5 //120
  149. _ShakeUvX("Shake X Multiplier", Range(0, 5)) = 1.5 //121
  150. _ShakeUvY("Shake Y Multiplier", Range(0, 5)) = 1 //122
  151. _ColorChangeTolerance("Tolerance", Range(0, 1)) = 0.25 //123
  152. _ColorChangeTarget("Color to change", Color) = (1, 0, 0, 1) //124
  153. _ColorChangeNewCol("New Color", Color) = (1, 1, 0, 1) //125
  154. _ColorChangeLuminosity("New Color Luminosity", Range(0, 1)) = 0.0 //126
  155. _RoundWaveStrength("Round Wave Strength", Range(0, 1)) = 0.7 //127
  156. _RoundWaveSpeed("Round Wave Speed", Range(0, 5)) = 2 //128
  157. [Toggle()] _BillboardY("Billboard on both axis?", float) = 0 //129
  158. _ShineColor("Shine Color", Color) = (1,1,1,1) // 130
  159. _ShineLocation("Shine Location", Range(0,1)) = 0.5 // 131
  160. _ShineWidth("Shine Width", Range(0.05,1)) = 0.1 // 132
  161. _ShineGlow("Shine Glow", Range(0,100)) = 1 // 133
  162. _ShineMask("Shine Mask", 2D) = "white" {} // 134
  163. _GlitchSize("Glitch Size", Range(0.25, 5)) = 1 //135
  164. [HideInInspector] _MinXUV("_MinXUV", Range(0, 1)) = 0.0
  165. [HideInInspector] _MaxXUV("_MaxXUV", Range(0, 1)) = 1.0
  166. [HideInInspector] _MinYUV("_MinYUV", Range(0, 1)) = 0.0
  167. [HideInInspector] _MaxYUV("_MaxYUV", Range(0, 1)) = 1.0
  168. [HideInInspector] _RandomSeed("_MaxYUV", Range(0, 10000)) = 0.0
  169. _StencilComp ("Stencil Comparison", Float) = 8
  170. _Stencil ("Stencil ID", Float) = 0
  171. _StencilOp ("Stencil Operation", Float) = 0
  172. _StencilWriteMask ("Stencil Write Mask", Float) = 255
  173. _StencilReadMask ("Stencil Read Mask", Float) = 255
  174. _ColorMask ("Color Mask", Float) = 15
  175. }
  176. SubShader
  177. {
  178. Tags { "Queue" = "Transparent" "CanUseSpriteAtlas" = "True" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" }
  179. Blend SrcAlpha OneMinusSrcAlpha
  180. Cull Off
  181. ZWrite Off
  182. ZTest [unity_GUIZTestMode]
  183. //The same than the original shader but with the stencil config needed for the scroll view
  184. Stencil
  185. {
  186. Ref [_Stencil]
  187. Comp [_StencilComp]
  188. Pass [_StencilOp]
  189. ReadMask [_StencilReadMask]
  190. WriteMask [_StencilWriteMask]
  191. }
  192. Pass
  193. {
  194. CGPROGRAM
  195. #pragma vertex vert
  196. #pragma fragment frag
  197. #pragma shader_feature GLOWTEX_ON
  198. #pragma shader_feature OUTBASE8DIR_ON
  199. #pragma shader_feature OUTBASEPIXELPERF_ON
  200. #pragma shader_feature OUTGREYTEXTURE_ON
  201. #pragma shader_feature COLORRAMPOUTLINE_ON
  202. #pragma shader_feature GREYSCALEOUTLINE_ON
  203. #pragma shader_feature POSTERIZEOUTLINE_ON
  204. #pragma shader_feature BLURISHD_ON
  205. #pragma shader_feature MANUALWIND_ON
  206. #pragma shader_feature RECTSIZE_ON
  207. #pragma shader_feature OFFSETUV_ON
  208. #pragma shader_feature CLIPPING_ON
  209. #pragma shader_feature POLARUV_ON
  210. #pragma shader_feature TWISTUV_ON
  211. #pragma shader_feature ROTATEUV_ON
  212. #pragma shader_feature FISHEYE_ON
  213. #pragma shader_feature PINCH_ON
  214. #pragma shader_feature SHAKEUV_ON
  215. #pragma shader_feature WAVEUV_ON
  216. #pragma shader_feature ROUNDWAVEUV_ON
  217. #pragma shader_feature DOODLE_ON
  218. #pragma shader_feature ZOOMUV_ON
  219. #pragma shader_feature FADE_ON
  220. #pragma shader_feature TEXTURESCROLL_ON
  221. #pragma shader_feature GLOW_ON
  222. #pragma shader_feature OUTBASE_ON
  223. #pragma shader_feature OUTTEX_ON
  224. #pragma shader_feature OUTDIST_ON
  225. #pragma shader_feature DISTORT_ON
  226. #pragma shader_feature WIND_ON
  227. #pragma shader_feature GRADIENT_ON
  228. #pragma shader_feature COLORSWAP_ON
  229. #pragma shader_feature HSV_ON
  230. #pragma shader_feature HITEFFECT_ON
  231. #pragma shader_feature PIXELATE_ON
  232. #pragma shader_feature NEGATIVE_ON
  233. #pragma shader_feature COLORRAMP_ON
  234. #pragma shader_feature GREYSCALE_ON
  235. #pragma shader_feature POSTERIZE_ON
  236. #pragma shader_feature BLUR_ON
  237. #pragma shader_feature MOTIONBLUR_ON
  238. #pragma shader_feature GHOST_ON
  239. #pragma shader_feature INNEROUTLINE_ON
  240. #pragma shader_feature HOLOGRAM_ON
  241. #pragma shader_feature CHROMABERR_ON
  242. #pragma shader_feature GLITCH_ON
  243. #pragma shader_feature FLICKER_ON
  244. #pragma shader_feature SHADOW_ON
  245. #pragma shader_feature SHINE_ON
  246. #pragma shader_feature ALPHACUTOFF_ON
  247. #pragma shader_feature CHANGECOLOR_ON
  248. #pragma shader_feature ATLAS_ON
  249. #pragma shader_feature BILBOARD_ON
  250. #pragma shader_feature BILBOARDY_ON
  251. #include "UnityCG.cginc"
  252. #include "AllIn1OneShaderFunctions.cginc"
  253. struct appdata
  254. {
  255. half4 vertex : POSITION;
  256. half2 uv : TEXCOORD0;
  257. half4 color : COLOR;
  258. };
  259. struct v2f
  260. {
  261. float2 uv : TEXCOORD0;
  262. half4 vertex : SV_POSITION;
  263. half4 color : COLOR;
  264. #if OUTTEX_ON
  265. half2 uvOutTex : TEXCOORD1;
  266. #endif
  267. #if OUTDIST_ON
  268. half2 uvOutDistTex : TEXCOORD2;
  269. #endif
  270. #if DISTORT_ON
  271. half2 uvDistTex : TEXCOORD3;
  272. #endif
  273. #if FADE_ON
  274. half2 uvFadeTex1 : TEXCOORD4;
  275. half2 uvFadeTex2 : TEXCOORD5;
  276. #endif
  277. };
  278. sampler2D _MainTex;
  279. half4 _MainTex_ST, _MainTex_TexelSize, _Color;
  280. half _Alpha, _RandomSeed;
  281. #if ATLAS_ON
  282. half _MinXUV, _MaxXUV, _MinYUV, _MaxYUV;
  283. #endif
  284. #if RECTSIZE_ON
  285. half _RectSize;
  286. #endif
  287. #if OFFSETUV_ON
  288. half _OffsetUvX, _OffsetUvY;
  289. #endif
  290. #if CLIPPING_ON
  291. half _ClipUvLeft, _ClipUvRight, _ClipUvUp, _ClipUvDown;
  292. #endif
  293. #if TWISTUV_ON
  294. half _TwistUvAmount, _TwistUvPosX, _TwistUvPosY, _TwistUvRadius;
  295. #endif
  296. #if ROTATEUV_ON
  297. half _RotateUvAmount;
  298. #endif
  299. #if FISHEYE_ON
  300. half _FishEyeUvAmount;
  301. #endif
  302. #if PINCH_ON
  303. half _PinchUvAmount;
  304. #endif
  305. #if DOODLE_ON
  306. half _HandDrawnAmount, _HandDrawnSpeed;
  307. #endif
  308. #if SHAKEUV_ON
  309. half _ShakeUvSpeed, _ShakeUvX, _ShakeUvY;
  310. #endif
  311. #if WAVEUV_ON
  312. half _WaveAmount, _WaveSpeed, _WaveStrength, _WaveX, _WaveY;
  313. #endif
  314. #if ROUNDWAVEUV_ON
  315. half _RoundWaveStrength, _RoundWaveSpeed;
  316. #endif
  317. #if ZOOMUV_ON
  318. half _ZoomUvAmount;
  319. #endif
  320. #if FADE_ON
  321. sampler2D _FadeTex, _FadeBurnTex;
  322. half4 _FadeBurnColor, _FadeTex_ST, _FadeBurnTex_ST;
  323. half _FadeAmount, _FadeBurnWidth, _FadeBurnTransition,_FadeBurnGlow;
  324. #endif
  325. #if TEXTURESCROLL_ON
  326. half _TextureScrollXSpeed, _TextureScrollYSpeed;
  327. #endif
  328. #if GLOW_ON
  329. sampler2D _GlowTex;
  330. half4 _GlowColor;
  331. half _Glow;
  332. #endif
  333. #if OUTBASE_ON
  334. half4 _OutlineColor;
  335. half _OutlineAlpha, _OutlineGlow, _OutlineWidth;
  336. int _OutlinePixelWidth;
  337. #endif
  338. #if OUTTEX_ON
  339. sampler2D _OutlineTex;
  340. half4 _OutlineTex_ST;
  341. half _OutlineTexXSpeed, _OutlineTexYSpeed;
  342. #endif
  343. #if OUTDIST_ON
  344. sampler2D _OutlineDistortTex;
  345. half4 _OutlineDistortTex_ST;
  346. half _OutlineDistortTexXSpeed, _OutlineDistortTexYSpeed, _OutlineDistortAmount;
  347. #endif
  348. #if DISTORT_ON
  349. sampler2D _DistortTex;
  350. half4 _DistortTex_ST;
  351. half _DistortTexXSpeed, _DistortTexYSpeed, _DistortAmount;
  352. #endif
  353. #if WIND_ON
  354. half _GrassSpeed, _GrassWind, _GrassManualAnim;
  355. #endif
  356. #if GRADIENT_ON
  357. half _GradBlend;
  358. half4 _GradTopRightCol, _GradTopLeftCol, _GradBotRightCol, _GradBotLeftCol;
  359. #endif
  360. #if COLORSWAP_ON
  361. sampler2D _ColorSwapTex;
  362. half4 _ColorSwapRed, _ColorSwapGreen, _ColorSwapBlue;
  363. half _ColorSwapRedLuminosity, _ColorSwapGreenLuminosity, _ColorSwapBlueLuminosity;
  364. #endif
  365. #if HSV_ON
  366. half _HsvShift, _HsvSaturation, _HsvBright;
  367. #endif
  368. #if HITEFFECT_ON
  369. half4 _HitEffectColor;
  370. half _HitEffectGlow, _HitEffectBlend;
  371. #endif
  372. #if PIXELATE_ON
  373. half _PixelateSize;
  374. #endif
  375. #if NEGATIVE_ON
  376. half _NegativeAmount;
  377. #endif
  378. #if COLORRAMP_ON
  379. sampler2D _ColorRampTex;
  380. half _ColorRampLuminosity;
  381. #endif
  382. #if GREYSCALE_ON
  383. half _GreyscaleLuminosity;
  384. half4 _GreyscaleTintColor;
  385. #endif
  386. #if POSTERIZE_ON
  387. half _PosterizeNumColors, _PosterizeGamma;
  388. #endif
  389. #if BLUR_ON
  390. half _BlurIntensity;
  391. #endif
  392. #if MOTIONBLUR_ON
  393. half _MotionBlurAngle, _MotionBlurDist;
  394. #endif
  395. #if GHOST_ON
  396. half _GhostColorBoost, _GhostTransparency;
  397. #endif
  398. #if INNEROUTLINE_ON
  399. half _InnerOutlineThickness, _InnerOutlineAlpha, _InnerOutlineGlow;
  400. half4 _InnerOutlineColor;
  401. #endif
  402. #if HOLOGRAM_ON
  403. half _HologramStripesAmount, _HologramMinAlpha, _HologramUnmodAmount, _HologramStripesSpeed, _HologramMaxAlpha;
  404. #endif
  405. #if CHROMABERR_ON
  406. half _ChromAberrAmount, _ChromAberrAlpha;
  407. #endif
  408. #if GLITCH_ON
  409. half _GlitchAmount, _GlitchSize;
  410. #endif
  411. #if FLICKER_ON
  412. half _FlickerFreq, _FlickerPercent, _FlickerAlpha;
  413. #endif
  414. #if SHADOW_ON
  415. half _ShadowX, _ShadowY, _ShadowAlpha;
  416. half4 _ShadowColor;
  417. #endif
  418. #if SHINE_ON
  419. sampler2D _ShineMask;
  420. half4 _ShineColor;
  421. half _ShineLocation, _ShineWidth, _ShineGlow;
  422. #endif
  423. #if ALPHACUTOFF_ON
  424. half _AlphaCutoffValue;
  425. #endif
  426. #if CHANGECOLOR_ON
  427. half4 _ColorChangeNewCol, _ColorChangeTarget;
  428. half _ColorChangeTolerance, _ColorChangeLuminosity;
  429. #endif
  430. v2f vert(appdata v)
  431. {
  432. #if RECTSIZE_ON
  433. v.vertex.xyz += (v.vertex.xyz * (_RectSize - 1.0));
  434. #endif
  435. v2f o;
  436. o.vertex = UnityObjectToClipPos(v.vertex);
  437. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  438. o.color = v.color;
  439. #if POLARUV_ON
  440. o.uv = v.uv - 0.5f;
  441. #endif
  442. #if ROTATEUV_ON
  443. half2 uvC = v.uv;
  444. half cosAngle = cos(_RotateUvAmount);
  445. half sinAngle = sin(_RotateUvAmount);
  446. float2x2 rot = float2x2(cosAngle, -sinAngle, sinAngle, cosAngle);
  447. uvC -= half2(0.5, 0.5);
  448. o.uv = mul(rot, uvC);
  449. o.uv += half2(0.5, 0.5);
  450. #endif
  451. #if OUTTEX_ON
  452. o.uvOutTex = TRANSFORM_TEX(v.uv, _OutlineTex);
  453. #endif
  454. #if OUTDIST_ON
  455. o.uvOutDistTex = TRANSFORM_TEX(v.uv, _OutlineDistortTex);
  456. #endif
  457. #if DISTORT_ON
  458. o.uvDistTex = TRANSFORM_TEX(v.uv, _DistortTex);
  459. #endif
  460. #if FADE_ON
  461. o.uvFadeTex1 = TRANSFORM_TEX(v.uv, _FadeTex);
  462. o.uvFadeTex2 = TRANSFORM_TEX(v.uv, _FadeBurnTex);
  463. #endif
  464. return o;
  465. }
  466. half3 GetPixel(in int offsetX, in int offsetY, half2 uv, sampler2D tex)
  467. {
  468. return tex2D(tex, (uv + half2(offsetX * _MainTex_TexelSize.x, offsetY * _MainTex_TexelSize.y))).rgb;
  469. }
  470. half4 frag(v2f i) : SV_Target
  471. {
  472. half2 uvRect = i.uv;
  473. #if ATLAS_ON
  474. uvRect = half2((i.uv.x - _MinXUV) / (_MaxXUV - _MinXUV), (i.uv.y - _MinYUV) / (_MaxYUV - _MinYUV));
  475. #endif
  476. #if CLIPPING_ON
  477. half2 tiledUv = half2(i.uv.x / _MainTex_ST.x, i.uv.y / _MainTex_ST.y);
  478. #if ATLAS_ON
  479. tiledUv = half2((tiledUv.x - _MinXUV) / (_MaxXUV - _MinXUV), (tiledUv.y - _MinYUV) / (_MaxYUV - _MinYUV));
  480. #endif
  481. clip((1 - _ClipUvUp) - tiledUv.y);
  482. clip(tiledUv.y - _ClipUvDown);
  483. clip((1 - _ClipUvRight) - tiledUv.x);
  484. clip(tiledUv.x - _ClipUvLeft);
  485. #endif
  486. #if OFFSETUV_ON
  487. i.uv += half2(_OffsetUvX, _OffsetUvY);
  488. #endif
  489. #if POLARUV_ON
  490. i.uv = half2(atan2(i.uv.y, i.uv.x) / (2.0f * 3.141592653589f), length(i.uv));
  491. i.uv *= _MainTex_ST.xy;
  492. #endif
  493. #if TWISTUV_ON
  494. half2 tempUv = i.uv - half2(_TwistUvPosX * _MainTex_ST.x, _TwistUvPosY * _MainTex_ST.y);
  495. _TwistUvRadius *= (_MainTex_ST.x + _MainTex_ST.y) / 2;
  496. half percent = (_TwistUvRadius - length(tempUv)) / _TwistUvRadius;
  497. half theta = percent * percent * (2.0 * sin(_TwistUvAmount)) * 8.0;
  498. half s = sin(theta);
  499. half c = cos(theta);
  500. half beta = max(sign(_TwistUvRadius - length(tempUv)), 0.0);
  501. tempUv = half2(dot(tempUv, half2(c, -s)), dot(tempUv, half2(s, c))) * beta + tempUv * (1 - beta);
  502. tempUv += half2(_TwistUvPosX * _MainTex_ST.x, _TwistUvPosY * _MainTex_ST.y);
  503. i.uv = tempUv;
  504. #endif
  505. #if FISHEYE_ON
  506. half2 midF = 0.5 * _MainTex_ST.xy;
  507. half bind = length(midF);
  508. half2 dF = i.uv - midF;
  509. half dFlen = length(dF);
  510. half fishInt = (3.14159265359 / bind) * (_FishEyeUvAmount + 0.001);
  511. i.uv = midF + (dF / (max(0.0001, dFlen))) * tan(dFlen * fishInt) * bind / tan(bind * fishInt);
  512. #endif
  513. #if PINCH_ON
  514. half2 midP = 0.5 * _MainTex_ST.xy;
  515. float2 dP = i.uv - midP;
  516. float pinchInt = (3.141592 / length(midP)) * (-_PinchUvAmount + 0.001);
  517. i.uv = midP + normalize(dP) * atan(length(dP) * -pinchInt * 10.0) * 0.5 / atan(-pinchInt * 5);
  518. #endif
  519. #if DOODLE_ON
  520. half2 uvCopy = uvRect;
  521. _HandDrawnSpeed = (floor(_Time * 20 * _HandDrawnSpeed) / _HandDrawnSpeed) * _HandDrawnSpeed;
  522. uvCopy.x = sin((uvCopy.x * _HandDrawnAmount + _HandDrawnSpeed) * 4);
  523. uvCopy.y = cos((uvCopy.y * _HandDrawnAmount + _HandDrawnSpeed) * 4);
  524. i.uv = lerp(i.uv, i.uv + uvCopy, 0.0005 * _HandDrawnAmount);
  525. #endif
  526. #if SHAKEUV_ON
  527. half xShake = sin((_Time + _RandomSeed) * _ShakeUvSpeed * 500 * _ShakeUvX);
  528. half yShake = sin((_Time + _RandomSeed) * _ShakeUvSpeed * 500 * _ShakeUvY);
  529. i.uv += half2(xShake * 0.01, yShake * 0.01);
  530. #endif
  531. #if ZOOMUV_ON
  532. half2 center = half2(0.5 * _MainTex_ST.x, 0.5 * _MainTex_ST.y);
  533. i.uv -= center;
  534. i.uv = i.uv * _ZoomUvAmount;
  535. i.uv += center;
  536. #endif
  537. #if TEXTURESCROLL_ON
  538. i.uv.x += (_Time.y * _TextureScrollXSpeed) % 1;
  539. i.uv.y += (_Time.y * _TextureScrollYSpeed) % 1;
  540. #endif
  541. #if RECTSIZE_ON
  542. i.uv = i.uv.xy * (_RectSize).xx + (((-_RectSize * 0.5) + 0.5)).xx;
  543. #endif
  544. #if PIXELATE_ON
  545. i.uv = floor(i.uv * _PixelateSize) / _PixelateSize;
  546. #endif
  547. #if DISTORT_ON
  548. i.uvDistTex.x += (_Time * _DistortTexXSpeed) % 1;
  549. i.uvDistTex.y += (_Time * _DistortTexYSpeed) % 1;
  550. #if ATLAS_ON
  551. i.uvDistTex = half2((i.uvDistTex.x - _MinXUV) / (_MaxXUV - _MinXUV), (i.uvDistTex.y - _MinYUV) / (_MaxYUV - _MinYUV));
  552. #endif
  553. half distortAmnt = (tex2D(_DistortTex, i.uvDistTex).r - 0.5) * 0.2 * _DistortAmount;
  554. i.uv.x += distortAmnt;
  555. i.uv.y += distortAmnt;
  556. #endif
  557. #if WAVEUV_ON
  558. half2 uvWave = half2(_WaveX * _MainTex_ST.x, _WaveY * _MainTex_ST.y) - i.uv;
  559. #if ATLAS_ON
  560. uvWave = half2(_WaveX, _WaveY) - uvRect;
  561. #endif
  562. uvWave.x *= _ScreenParams.x / _ScreenParams.y;
  563. half angWave = (sqrt(dot(uvWave, uvWave)) * _WaveAmount) - ((_Time.y * _WaveSpeed) % 360);
  564. i.uv = i.uv + normalize(uvWave) * sin(angWave) * (_WaveStrength / 1000);
  565. #endif
  566. #if ROUNDWAVEUV_ON
  567. float xWave = ((0.5 * _MainTex_ST.x) - uvRect.x);
  568. float yWave = ((0.5 * _MainTex_ST.y) - uvRect.y) * (_ScreenParams.x / _ScreenParams.y);
  569. float ripple = -sqrt(xWave*xWave + yWave* yWave);
  570. i.uv += sin((ripple + _Time.y * (_RoundWaveSpeed/10.0)) / 0.015) * (_RoundWaveStrength/10.0);
  571. #endif
  572. #if WIND_ON
  573. #if !MANUALWIND_ON
  574. i.uv.x = fmod(abs(lerp(i.uv.x, i.uv.x + (_GrassWind * 0.01 * sin(_Time * _GrassSpeed * 10)), uvRect.y)), 1);
  575. #else
  576. i.uv.x = fmod(abs(lerp(i.uv.x, i.uv.x + (_GrassWind * 0.01 * _GrassManualAnim), uvRect.y)), 1);
  577. #endif
  578. #endif
  579. half4 col = tex2D(_MainTex, i.uv) * i.color;
  580. half originalAlpha = col.a;
  581. col.rgb *= col.a;
  582. #if GLITCH_ON
  583. half2 uvGlitch = uvRect;
  584. uvGlitch.y -= 0.5;
  585. half lineNoise = pow(rand2(floor(uvGlitch * half2(24., 19.) * _GlitchSize) * 4.0, _RandomSeed), 3.0) * _GlitchAmount
  586. * pow(rand2(floor(uvGlitch * half2(38., 14.) * _GlitchSize) * 4.0, _RandomSeed), 3.0);
  587. col = tex2D(_MainTex, i.uv + half2(lineNoise * 0.02 * rand2(half2(2.0, 1), _RandomSeed), 0)) * i.color;
  588. #endif
  589. #if CHROMABERR_ON
  590. half4 r = tex2D(_MainTex, i.uv + half2(_ChromAberrAmount/10, 0)) * i.color;
  591. half4 b = tex2D(_MainTex, i.uv + half2(-_ChromAberrAmount/10, 0)) * i.color;
  592. col = half4(r.r * r.a, col.g, b.b * b.a, max(max(r.a, b.a) * _ChromAberrAlpha, col.a));
  593. #endif
  594. #if FADE_ON
  595. half2 tiledUvFade1= i.uvFadeTex1;
  596. half2 tiledUvFade2 = i.uvFadeTex2;
  597. #if ATLAS_ON
  598. tiledUvFade1 = half2((tiledUvFade1.x - _MinXUV) / (_MaxXUV - _MinXUV), (tiledUvFade1.y - _MinYUV) / (_MaxYUV - _MinYUV));
  599. tiledUvFade2 = half2((tiledUvFade2.x - _MinXUV) / (_MaxXUV - _MinXUV), (tiledUvFade2.y - _MinYUV) / (_MaxYUV - _MinYUV));
  600. #endif
  601. half fadeTemp = tex2D(_FadeTex, tiledUvFade1).r;
  602. half fade = smoothstep(_FadeAmount + 0.01, _FadeAmount + _FadeBurnTransition, fadeTemp);
  603. half fadeBurn = smoothstep(_FadeAmount - _FadeBurnWidth, _FadeAmount - _FadeBurnWidth + 0.1, fadeTemp);
  604. col.a *= fade;
  605. _FadeBurnColor.rgb *= _FadeBurnGlow;
  606. col += fadeBurn * tex2D(_FadeBurnTex, tiledUvFade2) * _FadeBurnColor * originalAlpha * (1 - col.a);
  607. #endif
  608. #if BLUR_ON
  609. #if !BLURISHD_ON
  610. col = BlurHD(i.uv, _MainTex, _BlurIntensity) * i.color;
  611. #else
  612. col = Blur(i.uv, _MainTex, _BlurIntensity) * i.color;
  613. #endif
  614. #endif
  615. #if MOTIONBLUR_ON
  616. _MotionBlurAngle = _MotionBlurAngle * 3.1415926;
  617. #define rot(n) mul(n, float2x2(cos(_MotionBlurAngle), -sin(_MotionBlurAngle), sin(_MotionBlurAngle), cos(_MotionBlurAngle)))
  618. _MotionBlurDist = _MotionBlurDist * 0.005;
  619. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist, -_MotionBlurDist)));
  620. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist * 2, -_MotionBlurDist * 2)));
  621. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist * 3, -_MotionBlurDist * 3)));
  622. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist * 4, -_MotionBlurDist * 4)));
  623. col.rgb += tex2D(_MainTex, i.uv);
  624. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist, _MotionBlurDist)));
  625. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist * 2, _MotionBlurDist * 2)));
  626. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist * 3, _MotionBlurDist * 3)));
  627. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist * 4, _MotionBlurDist * 4)));
  628. col.rgb = col.rgb / 9;
  629. #endif
  630. half luminance = 0;
  631. #if COLORSWAP_ON
  632. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
  633. half4 swapMask = tex2D(_ColorSwapTex, i.uv);
  634. swapMask.rgb *= swapMask.a;
  635. half3 redSwap = _ColorSwapRed * swapMask.r * col.a * saturate(luminance + _ColorSwapRedLuminosity);
  636. half3 greenSwap = _ColorSwapGreen * swapMask.g * col.a * saturate(luminance + _ColorSwapGreenLuminosity);
  637. half3 blueSwap = _ColorSwapBlue * swapMask.b * col.a * saturate(luminance + _ColorSwapBlueLuminosity);
  638. col.rgb = col.rgb * saturate(1 - swapMask.r - swapMask.g - swapMask.b);
  639. col.rgb = col.rgb + redSwap + greenSwap + blueSwap;
  640. #endif
  641. #if NEGATIVE_ON
  642. col.rgb = lerp(col.rgb, 1 - col.rgb, _NegativeAmount);
  643. #endif
  644. #if COLORRAMP_ON && !COLORRAMPOUTLINE_ON
  645. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
  646. luminance = saturate(luminance + _ColorRampLuminosity);
  647. col.rgb = tex2D(_ColorRampTex, half2(luminance, 0)).rgb;
  648. #endif
  649. #if CHANGECOLOR_ON
  650. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
  651. luminance = saturate(luminance + _ColorChangeLuminosity);
  652. half3 dif = abs(col.rgb - _ColorChangeTarget.rgb);
  653. col.rgb = lerp(col.rgb, half3(luminance, luminance, luminance) * _ColorChangeNewCol.rgb,
  654. max(sign(1 - saturate(dif.x + dif.y + dif.z) - _ColorChangeTolerance), 0.0));
  655. #endif
  656. #if GREYSCALE_ON && !GREYSCALEOUTLINE_ON
  657. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
  658. luminance = saturate(luminance + _GreyscaleLuminosity);
  659. col.rgb = half3(luminance, luminance, luminance) * _GreyscaleTintColor;
  660. #endif
  661. #if POSTERIZE_ON && !POSTERIZEOUTLINE_ON
  662. col.rgb = pow(col.rgb, _PosterizeGamma) * _PosterizeNumColors;
  663. col.rgb = floor(col.rgb) / _PosterizeNumColors;
  664. col.rgb = pow(col.rgb, 1.0 / _PosterizeGamma);
  665. #endif
  666. #if GHOST_ON
  667. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
  668. col.a = saturate(luminance - _GhostTransparency) * col.a;
  669. col.rgb *= luminance + _GhostColorBoost;
  670. #endif
  671. #if INNEROUTLINE_ON
  672. half3 innerT = abs(GetPixel(0, _InnerOutlineThickness, i.uv, _MainTex) - GetPixel(0, -_InnerOutlineThickness, i.uv, _MainTex));
  673. innerT += abs(GetPixel(_InnerOutlineThickness, 0, i.uv, _MainTex) - GetPixel(-_InnerOutlineThickness, 0, i.uv, _MainTex));
  674. innerT /= 2.0;
  675. innerT *= col.a * _InnerOutlineAlpha;
  676. col.rgb += length(innerT) * _InnerOutlineColor.rgb * _InnerOutlineGlow;
  677. #endif
  678. #if HITEFFECT_ON
  679. col.rgb = lerp(col.rgb, _HitEffectColor.rgb * _HitEffectGlow, _HitEffectBlend);
  680. #endif
  681. #if GRADIENT_ON
  682. half2 tiledUvGrad = half2(uvRect.x / _MainTex_ST.x, uvRect.y / _MainTex_ST.y);
  683. half _GradBoost = 1.2;
  684. half4 vertical = lerp(lerp(_GradBotLeftCol, _GradBotRightCol, tiledUvGrad.x * _GradBoost),
  685. lerp(_GradTopLeftCol, _GradTopRightCol, tiledUvGrad.x * _GradBoost), tiledUvGrad.y * _GradBoost);
  686. col.rgb = lerp(col.rgb, vertical.rgb, _GradBlend) * col.a;
  687. #endif
  688. //OUTLINE-------------------------------------------------------------
  689. #if OUTBASE_ON
  690. #ifdef OUTBASEPIXELPERF_ON
  691. half2 destUv = half2(_OutlinePixelWidth * _MainTex_TexelSize.x, _OutlinePixelWidth * _MainTex_TexelSize.y);
  692. #else
  693. half2 destUv = half2(_OutlineWidth * _MainTex_TexelSize.x * 200, _OutlineWidth * _MainTex_TexelSize.y * 200);
  694. #endif
  695. #if OUTDIST_ON
  696. i.uvOutDistTex.x += (_Time * _OutlineDistortTexXSpeed) % 1;
  697. i.uvOutDistTex.y += (_Time * _OutlineDistortTexYSpeed) % 1;
  698. #if ATLAS_ON
  699. i.uvOutDistTex = half2((i.uvOutDistTex.x - _MinXUV) / (_MaxXUV - _MinXUV), (i.uvOutDistTex.y - _MinYUV) / (_MaxYUV - _MinYUV));
  700. #endif
  701. half outDistortAmnt = (tex2D(_OutlineDistortTex, i.uvOutDistTex).r - 0.5) * 0.2 * _OutlineDistortAmount;
  702. destUv.x += outDistortAmnt;
  703. destUv.y += outDistortAmnt;
  704. #endif
  705. half spriteLeft = tex2D(_MainTex, i.uv + half2(destUv.x, 0)).a;
  706. half spriteRight = tex2D(_MainTex, i.uv - half2(destUv.x, 0)).a;
  707. half spriteBottom = tex2D(_MainTex, i.uv + half2(0, destUv.y)).a;
  708. half spriteTop = tex2D(_MainTex, i.uv - half2(0, destUv.y)).a;
  709. half result = spriteLeft + spriteRight + spriteBottom + spriteTop;
  710. #if OUTBASE8DIR_ON
  711. half spriteTopLeft = tex2D(_MainTex, i.uv + half2(destUv.x, destUv.y)).a;
  712. half spriteTopRight = tex2D(_MainTex, i.uv + half2(-destUv.x, destUv.y)).a;
  713. half spriteBotLeft = tex2D(_MainTex, i.uv + half2(destUv.x, -destUv.y)).a;
  714. half spriteBotRight = tex2D(_MainTex, i.uv + half2(-destUv.x, -destUv.y)).a;
  715. result = result + spriteTopLeft + spriteTopRight + spriteBotLeft + spriteBotRight;
  716. #endif
  717. result = step(0.05, saturate(result));
  718. #if OUTTEX_ON
  719. i.uvOutTex.x += (_Time * _OutlineTexXSpeed) % 1;
  720. i.uvOutTex.y += (_Time * _OutlineTexYSpeed) % 1;
  721. #if ATLAS_ON
  722. i.uvOutTex = half2((i.uvOutTex.x - _MinXUV) / (_MaxXUV - _MinXUV), (i.uvOutTex.y - _MinYUV) / (_MaxYUV - _MinYUV));
  723. #endif
  724. half4 tempOutColor = tex2D(_OutlineTex, i.uvOutTex);
  725. #if OUTGREYTEXTURE_ON
  726. luminance = 0.3 * tempOutColor.r + 0.59 * tempOutColor.g + 0.11 * tempOutColor.b;
  727. tempOutColor = half4(luminance, luminance, luminance, 1);
  728. #endif
  729. tempOutColor *= _OutlineColor;
  730. _OutlineColor = tempOutColor;
  731. #endif
  732. result *= (1 - originalAlpha) *_OutlineAlpha;
  733. half4 outline = result * _OutlineColor;
  734. outline.rgb *= _OutlineGlow * 2;
  735. col += outline;
  736. #endif
  737. //-----------------------------------------------------------------------------
  738. #if SHADOW_ON
  739. half shadowA = tex2D(_MainTex, i.uv + half2(_ShadowX, _ShadowY)).a;
  740. col.rgb += (_ShadowColor * shadowA) * (1 - col.a);
  741. col.a = max(shadowA * _ShadowAlpha * i.color.a, col.a);
  742. #endif
  743. #if GLOW_ON
  744. half4 emission;
  745. #if GLOWTEX_ON
  746. emission = tex2D(_GlowTex, i.uv);
  747. #else
  748. emission = col;
  749. #endif
  750. emission.rgb *= emission.a * col.a * _Glow * _GlowColor;
  751. col.rgb += emission.rgb;
  752. #endif
  753. #if COLORRAMP_ON && COLORRAMPOUTLINE_ON
  754. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
  755. luminance = saturate(luminance + _ColorRampLuminosity);
  756. col.rgb = tex2D(_ColorRampTex, half2(luminance, 0)).rgb;
  757. #endif
  758. #if GREYSCALE_ON && GREYSCALEOUTLINE_ON
  759. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
  760. luminance = saturate(luminance + _GreyscaleLuminosity);
  761. col.rgb = half3(luminance, luminance, luminance) * _GreyscaleTintColor;
  762. #endif
  763. #if POSTERIZE_ON && POSTERIZEOUTLINE_ON
  764. col.rgb = pow(col.rgb, _PosterizeGamma) * _PosterizeNumColors;
  765. col.rgb = floor(col.rgb) / _PosterizeNumColors;
  766. col.rgb = pow(col.rgb, 1.0 / _PosterizeGamma);
  767. #endif
  768. #if HSV_ON
  769. half3 resultHsv = half3(col.rgb);
  770. half cosHsv = _HsvBright * _HsvSaturation * cos(_HsvShift * 3.14159265 / 180);
  771. half sinHsv = _HsvBright * _HsvSaturation * sin(_HsvShift * 3.14159265 / 180);
  772. resultHsv.x = (.299 * _HsvBright + .701 * cosHsv + .168 * sinHsv) * col.x
  773. + (.587 * _HsvBright - .587 * cosHsv + .330 * sinHsv) * col.y
  774. + (.114 * _HsvBright - .114 * cosHsv - .497 * sinHsv) * col.z;
  775. resultHsv.y = (.299 * _HsvBright - .299 * cosHsv - .328 * sinHsv) *col.x
  776. + (.587 * _HsvBright + .413 * cosHsv + .035 * sinHsv) * col.y
  777. + (.114 * _HsvBright - .114 * cosHsv + .292 * sinHsv) * col.z;
  778. resultHsv.z = (.299 * _HsvBright - .3 * cosHsv + 1.25 * sinHsv) * col.x
  779. + (.587 * _HsvBright - .588 * cosHsv - 1.05 * sinHsv) * col.y
  780. + (.114 * _HsvBright + .886 * cosHsv - .203 * sinHsv) * col.z;
  781. col.rgb = resultHsv;
  782. #endif
  783. #if SHINE_ON
  784. half shineMask = tex2D(_ShineMask, i.uv).a;
  785. half lowLevel = _ShineLocation - _ShineWidth;
  786. half highLevel = _ShineLocation + _ShineWidth;
  787. half currentDistanceProjection = (i.uv.x + i.uv.y) / 2;
  788. half whitePower = 1 - (abs(currentDistanceProjection - _ShineLocation) / _ShineWidth);
  789. col.rgb += col.a * whitePower * _ShineGlow * (currentDistanceProjection > lowLevel) * (currentDistanceProjection < highLevel) * _ShineColor * shineMask;
  790. #endif
  791. col.a *= _Alpha;
  792. #if ALPHACUTOFF_ON
  793. clip((1 - _AlphaCutoffValue) - (1 - col.a) - 0.01);
  794. #endif
  795. #if HOLOGRAM_ON
  796. half totalHologram = _HologramStripesAmount + _HologramUnmodAmount;
  797. half hologramYCoord = ((uvRect.y + (((_Time.x + _RandomSeed) % 1) * _HologramStripesSpeed)) % totalHologram) / totalHologram;
  798. half alpha = RemapFloat(saturate(hologramYCoord - (_HologramUnmodAmount/totalHologram)), 0.0, 1.0, _HologramMinAlpha, saturate(_HologramMaxAlpha));
  799. col.a *= lerp(alpha, 1, max(sign((_HologramUnmodAmount/totalHologram) - hologramYCoord), 0.0));
  800. col.rgb *= max(1, _HologramMaxAlpha * max(sign(hologramYCoord - (_HologramUnmodAmount/totalHologram)), 0.0));
  801. #endif
  802. #if FLICKER_ON
  803. col.a *= saturate(col.a * step(frac(0.05 + (_Time.w + _RandomSeed) * _FlickerFreq), 1 - _FlickerPercent) + _FlickerAlpha);
  804. #endif
  805. col *= _Color;
  806. return col;
  807. }
  808. ENDCG
  809. }
  810. }
  811. CustomEditor "AllIn1SpriteShaderStencil"
  812. Fallback "Sprites/Default"
  813. }