图片流光效果:https://github.com/rubbyzhang/Unity_Image_Flash_Effect

    1. Shader "AllIn1SpriteShader/AllIn1SpriteShaderUiMask"
    2. {
    3. Properties
    4. {
    5. _MainTex ("Main Texture", 2D) = "white" {} //0
    6. _Color("Main Color", Color) = (1,1,1,1) //1
    7. _Alpha("General Alpha", Range(0,1)) = 1 //2
    8. _GlowColor("Glow Color", Color) = (1,1,1,1) //3
    9. _Glow("Glow Color Intensity", Range(0,100)) = 10 //4
    10. _GlowGlobal("Global Glow Intensity", Range(1,100)) = 1 //5
    11. [NoScaleOffset] _GlowTex("Glow Texture", 2D) = "white" {} //6
    12. _FadeTex("Fade Texture", 2D) = "white" {} //7
    13. _FadeAmount("Fade Amount", Range(-0.1,1)) = -0.1 //8
    14. _FadeBurnWidth("Fade Burn Width", Range(0,1)) = 0.025 //9
    15. _FadeBurnTransition("Burn Transition", Range(0.01,0.5)) = 0.075 //10
    16. _FadeBurnColor("Fade Burn Color", Color) = (1,1,0,1) //11
    17. _FadeBurnTex("Fade Burn Texture", 2D) = "white" {} //12
    18. _FadeBurnGlow("Fade Burn Glow", Range(1,250)) = 2//13
    19. _OutlineColor("Outline Base Color", Color) = (1,1,1,1) //14
    20. _OutlineAlpha("Outline Base Alpha", Range(0,1)) = 1 //15
    21. _OutlineGlow("Outline Base Glow", Range(1,100)) = 1.5 //16
    22. _OutlineWidth("Outline Base Width", Range(0,0.2)) = 0.004 //17
    23. _OutlinePixelWidth("Outline Base Pixel Width", Int) = 1 //18
    24. [Space]
    25. _OutlineTex("Outline Texture", 2D) = "white" {} //19
    26. _OutlineTexXSpeed("Texture scroll speed X", Range(-50,50)) = 10 //20
    27. _OutlineTexYSpeed("Texture scroll speed Y", Range(-50,50)) = 0 //21
    28. [Space]
    29. _OutlineDistortTex("Outline Distortion Texture", 2D) = "white" {} //22
    30. _OutlineDistortAmount("Outline Distortion Amount", Range(0,2)) = 0.5 //23
    31. _OutlineDistortTexXSpeed("Distortion scroll speed X", Range(-50,50)) = 5 //24
    32. _OutlineDistortTexYSpeed("Distortion scroll speed Y", Range(-50,50)) = 5 //25
    33. _AlphaOutlineColor("Color", Color) = (1, 1, 1, 1) //26
    34. _AlphaOutlineGlow("Outline Glow", Range(1,100)) = 5 //27
    35. _AlphaOutlinePower("Power", Range(0, 5)) = 1 // 28
    36. _AlphaOutlineMinAlpha("Min Alpha", Range(0, 1)) = 0 // 29
    37. _AlphaOutlineBlend("Blend", Range(0, 1)) = 1 // 30
    38. _GradBlend("Gradient Blend", Range(0,1)) = 1 //31
    39. _GradTopLeftCol("Top Color", Color) = (1,0,0,1) //32
    40. _GradTopRightCol("Top Color 2", Color) = (1, 1, 0, 1) //33
    41. _GradBotLeftCol("Bot Color", Color) = (0,0,1,1) //34
    42. _GradBotRightCol("Bot Color 2", Color) = (0, 1, 0, 1) //35
    43. [NoScaleOffset] _ColorSwapTex("Color Swap Texture", 2D) = "black" {} //36
    44. [HDR] _ColorSwapRed("Red Channel", Color) = (1,1,1,1) //37
    45. _ColorSwapRedLuminosity("Red luminosity", Range(-1,1)) = 0.5 //38
    46. [HDR] _ColorSwapGreen("Green Channel", Color) = (1,1,1,1) //39
    47. _ColorSwapGreenLuminosity("Green luminosity", Range(-1,1)) = 0.5 //40
    48. [HDR] _ColorSwapBlue("Blue Channel", Color) = (1,1,1,1) //41
    49. _ColorSwapBlueLuminosity("Blue luminosity", Range(-1,1)) = 0.5 //42
    50. _HsvShift("Hue Shift", Range(0, 360)) = 180 //43
    51. _HsvSaturation("Saturation", Range(0, 2)) = 1 //44
    52. _HsvBright("Brightness", Range(0, 2)) = 1 //45
    53. _HitEffectColor("Hit Effect Color", Color) = (1,1,1,1) //46
    54. _HitEffectGlow("Glow Intensity", Range(1,100)) = 5 //47
    55. [Space]
    56. _HitEffectBlend("Hit Effect Blend", Range(0,1)) = 1 //48
    57. _NegativeAmount("Negative Amount", Range(0, 1)) = 1 //49
    58. _PixelateSize("Pixelate size", Range(4,512)) = 32 //50
    59. [NoScaleOffset] _ColorRampTex("Color ramp Texture", 2D) = "white" {} //51
    60. _ColorRampLuminosity("Color ramp luminosity", Range(-1,1)) = 0 //52
    61. [Toggle()] _ColorRampOutline("Affects everything?", float) = 0 //53
    62. _GreyscaleLuminosity("Greyscale luminosity", Range(-1,1)) = 0 //54
    63. [Toggle()] _GreyscaleOutline("Affects everything?", float) = 0 //55
    64. _GreyscaleTintColor("Greyscale Tint Color", Color) = (1,1,1,1) //56
    65. _PosterizeNumColors("Number of Colors", Range(0,100)) = 8 //57
    66. _PosterizeGamma("Posterize Amount", Range(0.1,10)) = 0.75 //58
    67. [Toggle()] _PosterizeOutline("Affects everything?", float) = 0 //59
    68. _BlurIntensity("Blur Intensity", Range(0,100)) = 10 //60
    69. [Toggle()] _BlurHD("Blur is Low Res?", float) = 0 //61
    70. _MotionBlurAngle("Motion Blur Angle", Range(-1, 1)) = 0.1 //62
    71. _MotionBlurDist("Motion Blur Distance", Range(-3, 3)) = 1.25 //63
    72. _GhostColorBoost("Ghost Color Boost", Range(0,5)) = 1 //64
    73. _GhostTransparency("Ghost Transparency", Range(0,1)) = 0 //65
    74. _InnerOutlineColor("Inner Outline Color", Color) = (1,0,0,1) //66
    75. _InnerOutlineThickness("Outline Thickness", Range(0,3)) = 1 //67
    76. _InnerOutlineAlpha("Inner Outline Alpha", Range(0,1)) = 1 //68
    77. _InnerOutlineGlow("Inner Outline Glow", Range(1,250)) = 4 //69
    78. _AlphaCutoffValue("Alpha cutoff value", Range(0, 1)) = 0.25 //70
    79. [Toggle()] _OnlyOutline("Only render outline?", float) = 0 //71
    80. [Toggle()] _OnlyInnerOutline("Only render inner outline?", float) = 0 //72
    81. _HologramStripesAmount("Stripes Amount", Range(0, 1)) = 0.1 //73
    82. _HologramUnmodAmount("Unchanged Amount", Range(0, 1)) = 0.0 //74
    83. _HologramStripesSpeed("Stripes Speed", Range(-20, 20)) = 4.5 //75
    84. _HologramMinAlpha("Min Alpha", Range(0, 1)) = 0.1 //76
    85. _HologramMaxAlpha("Max Alpha", Range(0, 100)) = 0.75 //77
    86. _ChromAberrAmount("ChromAberr Amount", Range(0, 1)) = 1 //78
    87. _ChromAberrAlpha("ChromAberr Alpha", Range(0, 1)) = 0.4 //79
    88. _GlitchAmount("Glitch Amount", Range(0, 20)) = 3 //80
    89. _FlickerPercent("Flicker Percent", Range(0, 1)) = 0.05 //81
    90. _FlickerFreq("Flicker Frequency", Range(0, 5)) = 0.2 //82
    91. _FlickerAlpha("Flicker Alpha", Range(0, 1)) = 0 //83
    92. _ShadowX("Shadow X Axis", Range(-0.5, 0.5)) = 0.1 //84
    93. _ShadowY("Shadow Y Axis", Range(-0.5, 0.5)) = -0.05 //85
    94. _ShadowAlpha("Shadow Alpha", Range(0, 1)) = 0.5 //86
    95. _ShadowColor("Shadow Color", Color) = (0, 0, 0, 1) //87
    96. _HandDrawnAmount("Hand Drawn Amount", Range(0, 20)) = 10 //88
    97. _HandDrawnSpeed("Hand Drawn Speed", Range(1, 15)) = 5 //89
    98. _GrassSpeed("Speed", Range(0,50)) = 2 //90
    99. _GrassWind("Bend amount", Range(0,50)) = 20 //91
    100. [Space]
    101. [Toggle()] _GrassManualToggle("Manually animated?", float) = 0 //92
    102. _GrassManualAnim("Manual Anim Value", Range(-1,1)) = 1 //93
    103. _WaveAmount("Wave Amount", Range(0, 25)) = 7 //94
    104. _WaveSpeed("Wave Speed", Range(0, 25)) = 10 //95
    105. _WaveStrength("Wave Strength", Range(0, 25)) = 7.5 //96
    106. _WaveX("Wave X Axis", Range(0, 1)) = 0 //97
    107. _WaveY("Wave Y Axis", Range(0, 1)) = 0.5 //98
    108. _RectSize("Rect Size", Range(1, 4)) = 1 //99
    109. _OffsetUvX("X axis", Range(-1, 1)) = 0 //100
    110. _OffsetUvY("Y axis", Range(-1, 1)) = 0 //101
    111. _ClipUvLeft("Clipping Left", Range(0, 1)) = 0 //102
    112. _ClipUvRight("Clipping Right", Range(0, 1)) = 0 //103
    113. _ClipUvUp("Clipping Up", Range(0, 1)) = 0 //104
    114. _ClipUvDown("Clipping Down", Range(0, 1)) = 0 //105
    115. _TextureScrollXSpeed("Speed X Axis", Range(-5, 5)) = 1 //106
    116. _TextureScrollYSpeed("Speed Y Axis", Range(-5, 5)) = 0 //107
    117. _ZoomUvAmount("Zoom Amount", Range(0.1, 5)) = 0.5 //108
    118. _DistortTex("Distortion Texture", 2D) = "white" {} //109
    119. _DistortAmount("Distortion Amount", Range(0,2)) = 0.5 //110
    120. _DistortTexXSpeed("Scroll speed X", Range(-50,50)) = 5 //111
    121. _DistortTexYSpeed("Scroll speed Y", Range(-50,50)) = 5 //112
    122. _TwistUvAmount("Twist Amount", Range(0, 3.1416)) = 1 //113
    123. _TwistUvPosX("Twist Pos X Axis", Range(0, 1)) = 0.5 //114
    124. _TwistUvPosY("Twist Pos Y Axis", Range(0, 1)) = 0.5 //115
    125. _TwistUvRadius("Twist Radius", Range(0, 3)) = 0.75 //116
    126. _RotateUvAmount("Rotate Angle(radians)", Range(0, 6.2831)) = 0 //117
    127. _FishEyeUvAmount("Fish Eye Amount", Range(0, 0.5)) = 0.35 //118
    128. _PinchUvAmount("Pinch Amount", Range(0, 0.5)) = 0.35 //119
    129. _ShakeUvSpeed("Shake Speed", Range(0, 20)) = 2.5 //120
    130. _ShakeUvX("X Multiplier", Range(0, 5)) = 1.5 //121
    131. _ShakeUvY("Y Multiplier", Range(0, 5)) = 1 //122
    132. _ColorChangeTolerance("Tolerance", Range(0, 1)) = 0.25 //123
    133. _ColorChangeTarget("Color to change", Color) = (1, 0, 0, 1) //124
    134. [HDR] _ColorChangeNewCol("New Color", Color) = (1, 1, 0, 1) //125
    135. _ColorChangeLuminosity("New Color Luminosity", Range(0, 1)) = 0.0 //126
    136. _RoundWaveStrength("Wave Strength", Range(0, 1)) = 0.7 //127
    137. _RoundWaveSpeed("Wave Speed", Range(0, 5)) = 2 //128
    138. [Toggle()] _BillboardY("Billboard on both axis?", float) = 0 //129
    139. _ZWrite ("Depth Write", Float) = 0.0 // 130
    140. _MySrcMode ("SrcMode", Float) = 5 // 131
    141. _MyDstMode ("DstMode", Float) = 10 // 132
    142. _ShineColor("Shine Color", Color) = (1,1,1,1) // 133
    143. _ShineLocation("Shine Location", Range(0,1)) = 0.5 // 134
    144. _ShineRotate("Rotate Angle(radians)", Range(0, 6.2831)) = 0 //135
    145. _ShineWidth("Shine Width", Range(0.05,1)) = 0.1 // 136
    146. _ShineGlow("Shine Glow", Range(0,100)) = 1 // 137
    147. [NoScaleOffset] _ShineMask("Shine Mask", 2D) = "white" {} // 138
    148. _GlitchSize("Glitch Size", Range(0.25, 5)) = 1 //139
    149. _HologramStripeColor("Stripes Color", Color) = (0,1,1,1) //140
    150. _GradBoostX("Boost X axis", Range(0.1, 5)) = 1.2 //141
    151. _GradBoostY("Boost Y axis", Range(0.1, 5)) = 1.2 //142
    152. [Toggle()] _GradIsRadial("Radial Gradient?", float) = 0 //143
    153. _AlphaRoundThreshold("Round Threshold", Range(0.005, 1.0)) = 0.5 //144
    154. _GrassRadialBend("Radial Bend", Range(0.0, 5.0)) = 0.1 //145
    155. _ColorChangeTolerance2("Tolerance 2", Range(0, 1)) = 0.25 //146
    156. _ColorChangeTarget2("Color to change 2", Color) = (1, 0, 0, 1) //147
    157. [HDR] _ColorChangeNewCol2("New Color 2", Color) = (1, 1, 0, 1) //148
    158. _ColorChangeTolerance3("Tolerance 3", Range(0, 1)) = 0.25 //149
    159. _ColorChangeTarget3("Color to change 3", Color) = (1, 0, 0, 1) //150
    160. [HDR] _ColorChangeNewCol3("New Color 3", Color) = (1, 1, 0, 1) //151
    161. _Contrast ("Contrast", Range(0, 6)) = 1 // 152
    162. _Brightness ("Brightness", Range(-1, 1)) = 0 // 153
    163. _ColorSwapBlend ("Color Swap Blend", Range(0, 1)) = 1 // 154
    164. _ColorRampBlend ("Color Ramp Blend", Range(0, 1)) = 1 // 155
    165. _GreyscaleBlend ("Greyscale Blend", Range(0, 1)) = 1 // 156
    166. _GhostBlend ("Ghost Blend", Range(0, 1)) = 1 // 157
    167. _HologramBlend ("Hologram Blend", Range(0, 1)) = 1 // 158
    168. [AllIn1ShaderGradient] _ColorRampTexGradient("Color ramp Gradient", 2D) = "white" {} //159
    169. _OverlayTex("Overlay Texture", 2D) = "white" {} //160
    170. _OverlayColor("Overlay Color", Color) = (1, 1, 1, 1) //161
    171. _OverlayGlow("Overlay Glow", Range(0,25)) = 1 // 162
    172. _OverlayBlend("Overlay Blend", Range(0, 1)) = 1 // 163
    173. _Stencil ("Stencil ID", Float) = 0
    174. _StencilComp ("Stencil Comparison", Float) = 8
    175. _StencilOp ("Stencil Operation", Float) = 0
    176. _StencilWriteMask ("Stencil Write Mask", Float) = 255
    177. _StencilReadMask ("Stencil Read Mask", Float) = 255
    178. _ColorMask ("Color Mask", Float) = 15
    179. [HideInInspector] _MinXUV("_MinXUV", Range(0, 1)) = 0.0
    180. [HideInInspector] _MaxXUV("_MaxXUV", Range(0, 1)) = 1.0
    181. [HideInInspector] _MinYUV("_MinYUV", Range(0, 1)) = 0.0
    182. [HideInInspector] _MaxYUV("_MaxYUV", Range(0, 1)) = 1.0
    183. [HideInInspector] _RandomSeed("_MaxYUV", Range(0, 10000)) = 0.0
    184. _EditorDrawers("Editor Drawers", Int) = 6
    185. }
    186. SubShader
    187. {
    188. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
    189. Blend [_MySrcMode] [_MyDstMode]
    190. Cull Off
    191. ZWrite Off
    192. ZTest [unity_GUIZTestMode]
    193. ColorMask [_ColorMask]
    194. Stencil
    195. {
    196. Ref [_Stencil]
    197. Comp [_StencilComp]
    198. Pass [_StencilOp]
    199. ReadMask [_StencilReadMask]
    200. WriteMask [_StencilWriteMask]
    201. }
    202. Pass
    203. {
    204. CGPROGRAM
    205. #pragma vertex vert
    206. #pragma fragment frag
    207. #pragma shader_feature GLOW_ON
    208. #pragma shader_feature FADE_ON
    209. #pragma shader_feature OUTBASE_ON
    210. #pragma shader_feature ONLYOUTLINE_ON
    211. #pragma shader_feature GRADIENT_ON
    212. #pragma shader_feature GRADIENT2COL_ON
    213. #pragma shader_feature RADIALGRADIENT_ON
    214. #pragma shader_feature COLORSWAP_ON
    215. #pragma shader_feature HSV_ON
    216. #pragma shader_feature CHANGECOLOR_ON
    217. #pragma shader_feature CHANGECOLOR2_ON
    218. #pragma shader_feature CHANGECOLOR3_ON
    219. #pragma shader_feature COLORRAMP_ON
    220. #pragma shader_feature GRADIENTCOLORRAMP_ON
    221. #pragma shader_feature HITEFFECT_ON
    222. #pragma shader_feature NEGATIVE_ON
    223. #pragma shader_feature PIXELATE_ON
    224. #pragma shader_feature GREYSCALE_ON
    225. #pragma shader_feature POSTERIZE_ON
    226. #pragma shader_feature BLUR_ON
    227. #pragma shader_feature MOTIONBLUR_ON
    228. #pragma shader_feature GHOST_ON
    229. #pragma shader_feature ALPHAOUTLINE_ON
    230. #pragma shader_feature INNEROUTLINE_ON
    231. #pragma shader_feature ONLYINNEROUTLINE_ON
    232. #pragma shader_feature HOLOGRAM_ON
    233. #pragma shader_feature CHROMABERR_ON
    234. #pragma shader_feature GLITCH_ON
    235. #pragma shader_feature FLICKER_ON
    236. #pragma shader_feature SHADOW_ON
    237. #pragma shader_feature SHINE_ON
    238. #pragma shader_feature CONTRAST_ON
    239. #pragma shader_feature OVERLAY_ON
    240. #pragma shader_feature OVERLAYMULT_ON
    241. #pragma shader_feature ALPHACUTOFF_ON
    242. #pragma shader_feature ALPHAROUND_ON
    243. #pragma shader_feature DOODLE_ON
    244. #pragma shader_feature WIND_ON
    245. #pragma shader_feature WAVEUV_ON
    246. #pragma shader_feature ROUNDWAVEUV_ON
    247. #pragma shader_feature RECTSIZE_ON
    248. #pragma shader_feature OFFSETUV_ON
    249. #pragma shader_feature CLIPPING_ON
    250. #pragma shader_feature TEXTURESCROLL_ON
    251. #pragma shader_feature ZOOMUV_ON
    252. #pragma shader_feature DISTORT_ON
    253. #pragma shader_feature TWISTUV_ON
    254. #pragma shader_feature ROTATEUV_ON
    255. #pragma shader_feature POLARUV_ON
    256. #pragma shader_feature FISHEYE_ON
    257. #pragma shader_feature PINCH_ON
    258. #pragma shader_feature SHAKEUV_ON
    259. #pragma shader_feature GLOWTEX_ON
    260. #pragma shader_feature OUTTEX_ON
    261. #pragma shader_feature OUTDIST_ON
    262. #pragma shader_feature OUTBASE8DIR_ON
    263. #pragma shader_feature OUTBASEPIXELPERF_ON
    264. #pragma shader_feature COLORRAMPOUTLINE_ON
    265. #pragma shader_feature GREYSCALEOUTLINE_ON
    266. #pragma shader_feature POSTERIZEOUTLINE_ON
    267. #pragma shader_feature BLURISHD_ON
    268. #pragma shader_feature MANUALWIND_ON
    269. #pragma shader_feature ATLAS_ON
    270. #pragma shader_feature PREMULTIPLYALPHA_ON
    271. #pragma multi_compile _ UNITY_UI_CLIP_RECT
    272. #pragma multi_compile _ UNITY_UI_ALPHACLIP
    273. #include "UnityCG.cginc"
    274. #include "AllIn1OneShaderFunctions.cginc"
    275. struct appdata
    276. {
    277. float4 vertex : POSITION;
    278. float2 uv : TEXCOORD0;
    279. half4 color : COLOR;
    280. UNITY_VERTEX_INPUT_INSTANCE_ID
    281. };
    282. struct v2f
    283. {
    284. float2 uv : TEXCOORD0;
    285. float4 vertex : SV_POSITION;
    286. half4 color : COLOR;
    287. #if OUTTEX_ON
    288. half2 uvOutTex : TEXCOORD1;
    289. #endif
    290. #if OUTDIST_ON
    291. half2 uvOutDistTex : TEXCOORD2;
    292. #endif
    293. #if DISTORT_ON
    294. half2 uvDistTex : TEXCOORD3;
    295. #endif
    296. #if UNITY_UI_CLIP_RECT
    297. half4 mask : TEXCOORD4;
    298. #endif
    299. UNITY_VERTEX_OUTPUT_STEREO
    300. };
    301. #if UNITY_UI_CLIP_RECT
    302. float4 _ClipRect;
    303. half _UIMaskSoftnessX, _UIMaskSoftnessY;
    304. #endif
    305. sampler2D _MainTex;
    306. half4 _MainTex_ST, _MainTex_TexelSize, _Color;
    307. half _Alpha;
    308. float _RandomSeed;
    309. #if ATLAS_ON
    310. half _MinXUV, _MaxXUV, _MinYUV, _MaxYUV;
    311. #endif
    312. #if RECTSIZE_ON
    313. half _RectSize;
    314. #endif
    315. #if OFFSETUV_ON
    316. half _OffsetUvX, _OffsetUvY;
    317. #endif
    318. #if CLIPPING_ON
    319. half _ClipUvLeft, _ClipUvRight, _ClipUvUp, _ClipUvDown;
    320. #endif
    321. #if TWISTUV_ON
    322. half _TwistUvAmount, _TwistUvPosX, _TwistUvPosY, _TwistUvRadius;
    323. #endif
    324. #if ROTATEUV_ON
    325. half _RotateUvAmount;
    326. #endif
    327. #if FISHEYE_ON
    328. half _FishEyeUvAmount;
    329. #endif
    330. #if PINCH_ON
    331. half _PinchUvAmount;
    332. #endif
    333. #if DOODLE_ON
    334. half _HandDrawnAmount, _HandDrawnSpeed;
    335. #endif
    336. #if SHAKEUV_ON
    337. half _ShakeUvSpeed, _ShakeUvX, _ShakeUvY;
    338. #endif
    339. #if WAVEUV_ON
    340. float _WaveAmount, _WaveSpeed, _WaveStrength, _WaveX, _WaveY;
    341. #endif
    342. #if ROUNDWAVEUV_ON
    343. half _RoundWaveStrength, _RoundWaveSpeed;
    344. #endif
    345. #if ZOOMUV_ON
    346. half _ZoomUvAmount;
    347. #endif
    348. #if FADE_ON
    349. sampler2D _FadeTex, _FadeBurnTex;
    350. half4 _FadeBurnColor, _FadeTex_ST, _FadeBurnTex_ST;
    351. half _FadeAmount, _FadeBurnWidth, _FadeBurnTransition,_FadeBurnGlow;
    352. #endif
    353. #if TEXTURESCROLL_ON
    354. half _TextureScrollXSpeed, _TextureScrollYSpeed;
    355. #endif
    356. #if GLOW_ON
    357. sampler2D _GlowTex;
    358. half4 _GlowColor;
    359. half _Glow, _GlowGlobal;
    360. #endif
    361. #if OUTBASE_ON
    362. half4 _OutlineColor;
    363. half _OutlineAlpha, _OutlineGlow, _OutlineWidth;
    364. int _OutlinePixelWidth;
    365. #endif
    366. #if OUTTEX_ON
    367. sampler2D _OutlineTex;
    368. half4 _OutlineTex_ST;
    369. half _OutlineTexXSpeed, _OutlineTexYSpeed;
    370. #endif
    371. #if OUTDIST_ON
    372. sampler2D _OutlineDistortTex;
    373. half4 _OutlineDistortTex_ST;
    374. half _OutlineDistortTexXSpeed, _OutlineDistortTexYSpeed, _OutlineDistortAmount;
    375. #endif
    376. #if DISTORT_ON
    377. sampler2D _DistortTex;
    378. half4 _DistortTex_ST;
    379. half _DistortTexXSpeed, _DistortTexYSpeed, _DistortAmount;
    380. #endif
    381. #if WIND_ON
    382. half _GrassSpeed, _GrassWind, _GrassManualAnim, _GrassRadialBend;
    383. #endif
    384. #if GRADIENT_ON
    385. half _GradBlend, _GradBoostX, _GradBoostY;
    386. half4 _GradTopRightCol, _GradTopLeftCol, _GradBotRightCol, _GradBotLeftCol;
    387. #endif
    388. #if COLORSWAP_ON
    389. sampler2D _ColorSwapTex;
    390. half4 _ColorSwapRed, _ColorSwapGreen, _ColorSwapBlue;
    391. half _ColorSwapRedLuminosity, _ColorSwapGreenLuminosity, _ColorSwapBlueLuminosity, _ColorSwapBlend;
    392. #endif
    393. #if HSV_ON
    394. half _HsvShift, _HsvSaturation, _HsvBright;
    395. #endif
    396. #if HITEFFECT_ON
    397. half4 _HitEffectColor;
    398. half _HitEffectGlow, _HitEffectBlend;
    399. #endif
    400. #if PIXELATE_ON
    401. half _PixelateSize;
    402. #endif
    403. #if NEGATIVE_ON
    404. half _NegativeAmount;
    405. #endif
    406. #if COLORRAMP_ON
    407. sampler2D _ColorRampTex, _ColorRampTexGradient;
    408. half _ColorRampLuminosity, _ColorRampBlend;
    409. #endif
    410. #if GREYSCALE_ON
    411. half _GreyscaleLuminosity, _GreyscaleBlend;
    412. half4 _GreyscaleTintColor;
    413. #endif
    414. #if POSTERIZE_ON
    415. half _PosterizeNumColors, _PosterizeGamma;
    416. #endif
    417. #if BLUR_ON
    418. half _BlurIntensity;
    419. #endif
    420. #if MOTIONBLUR_ON
    421. half _MotionBlurAngle, _MotionBlurDist;
    422. #endif
    423. #if GHOST_ON
    424. half _GhostColorBoost, _GhostTransparency, _GhostBlend;
    425. #endif
    426. #if ALPHAOUTLINE_ON
    427. half _AlphaOutlineGlow, _AlphaOutlinePower, _AlphaOutlineMinAlpha, _AlphaOutlineBlend;
    428. half4 _AlphaOutlineColor;
    429. #endif
    430. #if INNEROUTLINE_ON
    431. half _InnerOutlineThickness, _InnerOutlineAlpha, _InnerOutlineGlow;
    432. half4 _InnerOutlineColor;
    433. #endif
    434. #if HOLOGRAM_ON
    435. half _HologramStripesAmount, _HologramMinAlpha, _HologramUnmodAmount, _HologramStripesSpeed, _HologramMaxAlpha, _HologramBlend;
    436. half4 _HologramStripeColor;
    437. #endif
    438. #if CHROMABERR_ON
    439. half _ChromAberrAmount, _ChromAberrAlpha;
    440. #endif
    441. #if GLITCH_ON
    442. half _GlitchAmount, _GlitchSize;
    443. #endif
    444. #if FLICKER_ON
    445. half _FlickerFreq, _FlickerPercent, _FlickerAlpha;
    446. #endif
    447. #if SHADOW_ON
    448. half _ShadowX, _ShadowY, _ShadowAlpha;
    449. half4 _ShadowColor;
    450. #endif
    451. #if SHINE_ON
    452. sampler2D _ShineMask;
    453. half4 _ShineColor;
    454. half _ShineLocation, _ShineRotate, _ShineWidth, _ShineGlow;
    455. #endif
    456. #if ALPHACUTOFF_ON
    457. half _AlphaCutoffValue;
    458. #endif
    459. #if ALPHAROUND_ON
    460. half _AlphaRoundThreshold;
    461. #endif
    462. #if CHANGECOLOR_ON
    463. half4 _ColorChangeNewCol, _ColorChangeTarget;
    464. half _ColorChangeTolerance, _ColorChangeLuminosity;
    465. #endif
    466. #if CHANGECOLOR2_ON
    467. half4 _ColorChangeNewCol2, _ColorChangeTarget2;
    468. half _ColorChangeTolerance2;
    469. #endif
    470. #if CHANGECOLOR3_ON
    471. half4 _ColorChangeNewCol3, _ColorChangeTarget3;
    472. half _ColorChangeTolerance3;
    473. #endif
    474. #if CONTRAST_ON
    475. half _Contrast, _Brightness;
    476. #endif
    477. #if OVERLAY_ON
    478. sampler2D _OverlayTex;
    479. half4 _OverlayTex_ST, _OverlayColor;
    480. half _OverlayGlow, _OverlayBlend;
    481. #endif
    482. v2f vert(appdata v)
    483. {
    484. #if RECTSIZE_ON
    485. v.vertex.xyz += (v.vertex.xyz * (_RectSize - 1.0));
    486. #endif
    487. v2f o;
    488. UNITY_SETUP_INSTANCE_ID(v);
    489. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    490. UNITY_TRANSFER_INSTANCE_ID(v, o);
    491. o.vertex = UnityObjectToClipPos(v.vertex);
    492. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    493. o.color = v.color;
    494. #if UNITY_UI_CLIP_RECT
    495. half2 pixelSize = o.vertex.w;
    496. pixelSize /= half2(1, 1) * abs(mul((half2x2)UNITY_MATRIX_P, _ScreenParams.xy));
    497. half4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
    498. half2 maskUV = (v.vertex.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
    499. o.mask = half4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
    500. #endif
    501. half2 center = half2(0.5, 0.5);
    502. #if ATLAS_ON
    503. center = half2((_MaxXUV + _MinXUV) / 2.0, (_MaxYUV + _MinYUV) / 2.0);
    504. #endif
    505. #if POLARUV_ON
    506. o.uv = v.uv - center;
    507. #endif
    508. #if ROTATEUV_ON
    509. half2 uvC = v.uv;
    510. half cosAngle = cos(_RotateUvAmount);
    511. half sinAngle = sin(_RotateUvAmount);
    512. half2x2 rot = half2x2(cosAngle, -sinAngle, sinAngle, cosAngle);
    513. uvC -= center;
    514. o.uv = mul(rot, uvC);
    515. o.uv += center;
    516. #endif
    517. #if OUTTEX_ON
    518. o.uvOutTex = TRANSFORM_TEX(v.uv, _OutlineTex);
    519. #endif
    520. #if OUTDIST_ON
    521. o.uvOutDistTex = TRANSFORM_TEX(v.uv, _OutlineDistortTex);
    522. #endif
    523. #if DISTORT_ON
    524. o.uvDistTex = TRANSFORM_TEX(v.uv, _DistortTex);
    525. #endif
    526. return o;
    527. }
    528. half3 GetPixel(in int offsetX, in int offsetY, half2 uv, sampler2D tex)
    529. {
    530. return tex2D(tex, (uv + half2(offsetX * _MainTex_TexelSize.x, offsetY * _MainTex_TexelSize.y))).rgb;
    531. }
    532. half4 frag(v2f i) : SV_Target
    533. {
    534. float2 uvRect = i.uv;
    535. half2 center = half2(0.5, 0.5);
    536. #if ATLAS_ON
    537. center = half2((_MaxXUV + _MinXUV) / 2.0, (_MaxYUV + _MinYUV) / 2.0);
    538. uvRect = half2((i.uv.x - _MinXUV) / (_MaxXUV - _MinXUV), (i.uv.y - _MinYUV) / (_MaxYUV - _MinYUV));
    539. #endif
    540. half2 centerTiled = half2(center.x * _MainTex_ST.x, center.y * _MainTex_ST.y);
    541. #if CLIPPING_ON
    542. half2 tiledUv = half2(i.uv.x / _MainTex_ST.x, i.uv.y / _MainTex_ST.y);
    543. #if ATLAS_ON
    544. tiledUv = half2((tiledUv.x - _MinXUV) / (_MaxXUV - _MinXUV), (tiledUv.y - _MinYUV) / (_MaxYUV - _MinYUV));
    545. #endif
    546. clip((1 - _ClipUvUp) - tiledUv.y);
    547. clip(tiledUv.y - _ClipUvDown);
    548. clip((1 - _ClipUvRight) - tiledUv.x);
    549. clip(tiledUv.x - _ClipUvLeft);
    550. #endif
    551. #if TEXTURESCROLL_ON && ATLAS_ON
    552. i.uv = half2(_MinXUV + ((_MaxXUV - _MinXUV) * (abs(((_Time.y + _RandomSeed) * _TextureScrollXSpeed) + uvRect.x) % 1)),
    553. _MinYUV + ((_MaxYUV - _MinYUV) * (abs(((_Time.y + _RandomSeed) * _TextureScrollYSpeed) + uvRect.y) % 1)));
    554. #endif
    555. #if OFFSETUV_ON
    556. #if ATLAS_ON
    557. i.uv = half2(_MinXUV + ((_MaxXUV - _MinXUV) * (abs((_OffsetUvX + uvRect.x) % 1))),
    558. _MinYUV + ((_MaxYUV - _MinYUV) * (abs(_OffsetUvY + uvRect.y) % 1)));
    559. #else
    560. i.uv += half2(_OffsetUvX, _OffsetUvY);
    561. #endif
    562. #endif
    563. #if POLARUV_ON
    564. i.uv = half2(atan2(i.uv.y, i.uv.x) / (2.0f * 3.141592653589f), length(i.uv));
    565. i.uv *= _MainTex_ST.xy;
    566. #endif
    567. #if TWISTUV_ON
    568. #if ATLAS_ON
    569. _TwistUvPosX = ((_MaxXUV - _MinXUV) * _TwistUvPosX) + _MinXUV;
    570. _TwistUvPosY = ((_MaxYUV - _MinYUV) * _TwistUvPosY) + _MinYUV;
    571. #endif
    572. half2 tempUv = i.uv - half2(_TwistUvPosX * _MainTex_ST.x, _TwistUvPosY * _MainTex_ST.y);
    573. _TwistUvRadius *= (_MainTex_ST.x + _MainTex_ST.y) / 2;
    574. half percent = (_TwistUvRadius - length(tempUv)) / _TwistUvRadius;
    575. half theta = percent * percent * (2.0 * sin(_TwistUvAmount)) * 8.0;
    576. half s = sin(theta);
    577. half c = cos(theta);
    578. half beta = max(sign(_TwistUvRadius - length(tempUv)), 0.0);
    579. tempUv = half2(dot(tempUv, half2(c, -s)), dot(tempUv, half2(s, c))) * beta + tempUv * (1 - beta);
    580. tempUv += half2(_TwistUvPosX * _MainTex_ST.x, _TwistUvPosY * _MainTex_ST.y);
    581. i.uv = tempUv;
    582. #endif
    583. #if FISHEYE_ON
    584. half bind = length(centerTiled);
    585. half2 dF = i.uv - centerTiled;
    586. half dFlen = length(dF);
    587. half fishInt = (3.14159265359 / bind) * (_FishEyeUvAmount + 0.001);
    588. i.uv = centerTiled + (dF / (max(0.0001, dFlen))) * tan(dFlen * fishInt) * bind / tan(bind * fishInt);
    589. #endif
    590. #if PINCH_ON
    591. half2 dP = i.uv - centerTiled;
    592. half pinchInt = (3.141592 / length(centerTiled)) * (-_PinchUvAmount + 0.001);
    593. i.uv = centerTiled + normalize(dP) * atan(length(dP) * -pinchInt * 10.0) * 0.5 / atan(-pinchInt * 5);
    594. #endif
    595. #if ZOOMUV_ON
    596. i.uv -= centerTiled;
    597. i.uv = i.uv * _ZoomUvAmount;
    598. i.uv += centerTiled;
    599. #endif
    600. #if DOODLE_ON
    601. half2 uvCopy = uvRect;
    602. _HandDrawnSpeed = (floor((_Time + _RandomSeed) * 20 * _HandDrawnSpeed) / _HandDrawnSpeed) * _HandDrawnSpeed;
    603. uvCopy.x = sin((uvCopy.x * _HandDrawnAmount + _HandDrawnSpeed) * 4);
    604. uvCopy.y = cos((uvCopy.y * _HandDrawnAmount + _HandDrawnSpeed) * 4);
    605. i.uv = lerp(i.uv, i.uv + uvCopy, 0.0005 * _HandDrawnAmount);
    606. #endif
    607. #if SHAKEUV_ON
    608. half xShake = sin((_Time + _RandomSeed) * _ShakeUvSpeed * 50) * _ShakeUvX;
    609. half yShake = cos((_Time + _RandomSeed) * _ShakeUvSpeed * 50) * _ShakeUvY;
    610. i.uv += half2(xShake * 0.012, yShake * 0.01);
    611. #endif
    612. #if RECTSIZE_ON
    613. i.uv = i.uv.xy * (_RectSize).xx + (((-_RectSize * 0.5) + 0.5)).xx;
    614. #endif
    615. #if DISTORT_ON
    616. #if ATLAS_ON
    617. i.uvDistTex.x = i.uvDistTex.x * (1 / (_MaxXUV - _MinXUV));
    618. i.uvDistTex.y = i.uvDistTex.y * (1 / (_MaxYUV - _MinYUV));
    619. #endif
    620. i.uvDistTex.x += ((_Time + _RandomSeed) * _DistortTexXSpeed) % 1;
    621. i.uvDistTex.y += ((_Time + _RandomSeed) * _DistortTexYSpeed) % 1;
    622. half distortAmnt = (tex2D(_DistortTex, i.uvDistTex).r - 0.5) * 0.2 * _DistortAmount;
    623. i.uv.x += distortAmnt;
    624. i.uv.y += distortAmnt;
    625. #endif
    626. #if WAVEUV_ON
    627. float2 uvWave = half2(_WaveX * _MainTex_ST.x, _WaveY * _MainTex_ST.y) - i.uv;
    628. uvWave %= 1;
    629. #if ATLAS_ON
    630. uvWave = half2(_WaveX, _WaveY) - uvRect;
    631. #endif
    632. uvWave.x *= _ScreenParams.x / _ScreenParams.y;
    633. float waveTime = _Time.y + _RandomSeed;
    634. float angWave = (sqrt(dot(uvWave, uvWave)) * _WaveAmount) - ((waveTime * _WaveSpeed));
    635. i.uv = i.uv + uvWave * sin(angWave) * (_WaveStrength / 1000.0);
    636. #endif
    637. #if ROUNDWAVEUV_ON
    638. half xWave = ((0.5 * _MainTex_ST.x) - uvRect.x);
    639. half yWave = ((0.5 * _MainTex_ST.y) - uvRect.y) * (_MainTex_TexelSize.w / _MainTex_TexelSize.z);
    640. half ripple = -sqrt(xWave*xWave + yWave* yWave);
    641. i.uv += (sin((ripple + (_Time.y + _RandomSeed) * (_RoundWaveSpeed/10.0)) / 0.015) * (_RoundWaveStrength/10.0)) % 1;
    642. #endif
    643. #if WIND_ON
    644. half windOffset = sin((_Time + _RandomSeed) * _GrassSpeed * 10);
    645. half2 windCenter = half2(0.5, 0.1);
    646. #if ATLAS_ON
    647. windCenter.x = ((_MaxXUV - _MinXUV) * windCenter.x) + _MinXUV;
    648. windCenter.y = ((_MaxYUV - _MinYUV) * windCenter.y) + _MinYUV;
    649. #endif
    650. #if !MANUALWIND_ON
    651. i.uv.x = fmod(abs(lerp(i.uv.x, i.uv.x + (_GrassWind * 0.01 * windOffset), uvRect.y)), 1);
    652. #else
    653. i.uv.x = fmod(abs(lerp(i.uv.x, i.uv.x + (_GrassWind * 0.01 * _GrassManualAnim), uvRect.y)), 1);
    654. windOffset = _GrassManualAnim;
    655. #endif
    656. half2 delta = i.uv - windCenter;
    657. half delta2 = dot(delta.xy, delta.xy);
    658. half2 delta_offset = delta2 * windOffset;
    659. i.uv = i.uv + half2(delta.y, -delta.x) * delta_offset * _GrassRadialBend;
    660. #endif
    661. #if TEXTURESCROLL_ON && !ATLAS_ON
    662. i.uv.x += ((_Time.y + _RandomSeed) * _TextureScrollXSpeed) % 1;
    663. i.uv.y += ((_Time.y + _RandomSeed) * _TextureScrollYSpeed) % 1;
    664. #endif
    665. #if PIXELATE_ON
    666. i.uv = floor(i.uv * _PixelateSize) / _PixelateSize;
    667. #endif
    668. half4 col = tex2D(_MainTex, i.uv);
    669. half originalAlpha = col.a;
    670. col *= i.color;
    671. #if PREMULTIPLYALPHA_ON
    672. col.rgb *= col.a;
    673. #endif
    674. #if GLITCH_ON
    675. half2 uvGlitch = uvRect;
    676. uvGlitch.y -= 0.5;
    677. half lineNoise = pow(rand2(floor(uvGlitch * half2(24., 19.) * _GlitchSize) * 4.0, _RandomSeed), 3.0) * _GlitchAmount
    678. * pow(rand2(floor(uvGlitch * half2(38., 14.) * _GlitchSize) * 4.0, _RandomSeed), 3.0);
    679. col = tex2D(_MainTex, i.uv + half2(lineNoise * 0.02 * rand2(half2(2.0, 1), _RandomSeed), 0)) * i.color;
    680. #endif
    681. #if CHROMABERR_ON
    682. half4 r = tex2D(_MainTex, i.uv + half2(_ChromAberrAmount/10, 0)) * i.color;
    683. half4 b = tex2D(_MainTex, i.uv + half2(-_ChromAberrAmount/10, 0)) * i.color;
    684. col = half4(r.r * r.a, col.g, b.b * b.a, max(max(r.a, b.a) * _ChromAberrAlpha, col.a));
    685. #endif
    686. #if BLUR_ON
    687. #if ATLAS_ON
    688. #if !BLURISHD_ON
    689. col = BlurHD(i.uv, _MainTex, _BlurIntensity, (_MaxXUV - _MinXUV), (_MaxYUV - _MinYUV)) * i.color;
    690. #else
    691. col = Blur(i.uv, _MainTex, _BlurIntensity * (_MaxXUV - _MinXUV)) * i.color;
    692. #endif
    693. #else
    694. #if !BLURISHD_ON
    695. col = BlurHD(i.uv, _MainTex, _BlurIntensity, 1, 1) * i.color;
    696. #else
    697. col = Blur(i.uv, _MainTex, _BlurIntensity) * i.color;
    698. #endif
    699. #endif
    700. #endif
    701. #if MOTIONBLUR_ON
    702. _MotionBlurAngle = _MotionBlurAngle * 3.1415926;
    703. #define rot(n) mul(n, half2x2(cos(_MotionBlurAngle), -sin(_MotionBlurAngle), sin(_MotionBlurAngle), cos(_MotionBlurAngle)))
    704. _MotionBlurDist = _MotionBlurDist * 0.005;
    705. #if ATLAS_ON
    706. _MotionBlurDist *= (_MaxXUV - _MinXUV);
    707. #endif
    708. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist, -_MotionBlurDist)));
    709. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist * 2, -_MotionBlurDist * 2)));
    710. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist * 3, -_MotionBlurDist * 3)));
    711. col.rgb += tex2D(_MainTex, i.uv + rot(half2(-_MotionBlurDist * 4, -_MotionBlurDist * 4)));
    712. col.rgb += tex2D(_MainTex, i.uv);
    713. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist, _MotionBlurDist)));
    714. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist * 2, _MotionBlurDist * 2)));
    715. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist * 3, _MotionBlurDist * 3)));
    716. col.rgb += tex2D(_MainTex, i.uv + rot(half2(_MotionBlurDist * 4, _MotionBlurDist * 4)));
    717. col.rgb = col.rgb / 9;
    718. #endif
    719. #if NEGATIVE_ON
    720. col.rgb = lerp(col.rgb, 1 - col.rgb, _NegativeAmount);
    721. #endif
    722. half luminance = 0;
    723. #if GREYSCALE_ON && !GREYSCALEOUTLINE_ON
    724. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
    725. luminance = saturate(luminance + _GreyscaleLuminosity);
    726. col.rgb = lerp(col.rgb, half3(luminance, luminance, luminance) * _GreyscaleTintColor, _GreyscaleBlend);
    727. #endif
    728. #if GHOST_ON
    729. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
    730. half4 ghostResult;
    731. ghostResult.a = saturate(luminance - _GhostTransparency) * col.a;
    732. ghostResult.rgb = col.rgb * (luminance + _GhostColorBoost);
    733. col = lerp(col, ghostResult, _GhostBlend);
    734. #endif
    735. #if INNEROUTLINE_ON
    736. half3 innerT = abs(GetPixel(0, _InnerOutlineThickness, i.uv, _MainTex) - GetPixel(0, -_InnerOutlineThickness, i.uv, _MainTex));
    737. innerT += abs(GetPixel(_InnerOutlineThickness, 0, i.uv, _MainTex) - GetPixel(-_InnerOutlineThickness, 0, i.uv, _MainTex));
    738. #if !ONLYINNEROUTLINE_ON
    739. innerT = (innerT / 2.0) * col.a * _InnerOutlineAlpha;
    740. col.rgb += length(innerT) * _InnerOutlineColor.rgb * _InnerOutlineGlow;
    741. #else
    742. innerT *= col.a * _InnerOutlineAlpha;
    743. col.rgb = length(innerT) * _InnerOutlineColor.rgb * _InnerOutlineGlow;
    744. col.a = step(0.3, col.r+col.g+col.b);
    745. #endif
    746. #endif
    747. #if HITEFFECT_ON
    748. col.rgb = lerp(col.rgb, _HitEffectColor.rgb * _HitEffectGlow, _HitEffectBlend);
    749. #endif
    750. #if GRADIENT_ON
    751. half2 tiledUvGrad = half2(uvRect.x / _MainTex_ST.x, uvRect.y / _MainTex_ST.y);
    752. #if GRADIENT2COL_ON
    753. _GradTopRightCol = _GradTopLeftCol;
    754. _GradBotRightCol = _GradBotLeftCol;
    755. #endif
    756. #if RADIALGRADIENT_ON
    757. half radialDist = 1 - length(tiledUvGrad - half2(0.5, 0.5));
    758. radialDist *= (_MainTex_TexelSize.w / _MainTex_TexelSize.z);
    759. radialDist = saturate(_GradBoostX * radialDist);
    760. half4 gradientResult = lerp(_GradTopLeftCol, _GradBotLeftCol, radialDist);
    761. #else
    762. half gradXLerpFactor = saturate(pow(tiledUvGrad.x, _GradBoostX));
    763. half4 gradientResult = lerp(lerp(_GradBotLeftCol, _GradBotRightCol, gradXLerpFactor),
    764. lerp(_GradTopLeftCol, _GradTopRightCol, gradXLerpFactor), saturate(pow(tiledUvGrad.y, _GradBoostY)));
    765. #endif
    766. gradientResult = lerp(col, gradientResult, _GradBlend);
    767. col.rgb = gradientResult.rgb * col.a;
    768. col.a *= gradientResult.a;
    769. #endif
    770. #if CONTRAST_ON
    771. col.rgb = (col.rgb - float3(0.5, 0.5, 0.5)) * _Contrast + float3(0.5, 0.5, 0.5);
    772. col.rgb += _Brightness;
    773. #endif
    774. #if COLORSWAP_ON
    775. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
    776. half4 swapMask = tex2D(_ColorSwapTex, i.uv);
    777. swapMask.rgb *= swapMask.a;
    778. half3 redSwap = _ColorSwapRed * swapMask.r * saturate(luminance + _ColorSwapRedLuminosity);
    779. half3 greenSwap = _ColorSwapGreen * swapMask.g * saturate(luminance + _ColorSwapGreenLuminosity);
    780. half3 blueSwap = _ColorSwapBlue * swapMask.b * saturate(luminance + _ColorSwapBlueLuminosity);
    781. swapMask.rgb = col.rgb * saturate(1 - swapMask.r - swapMask.g - swapMask.b);
    782. col.rgb = lerp(col.rgb, swapMask.rgb + redSwap + greenSwap + blueSwap, _ColorSwapBlend);
    783. #endif
    784. #if COLORRAMP_ON && !COLORRAMPOUTLINE_ON
    785. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
    786. luminance = saturate(luminance + _ColorRampLuminosity);
    787. #if GRADIENTCOLORRAMP_ON
    788. col.rgb = lerp(col.rgb, tex2D(_ColorRampTexGradient, half2(luminance, 0)).rgb, _ColorRampBlend);
    789. #else
    790. col.rgb = lerp(col.rgb, tex2D(_ColorRampTex, half2(luminance, 0)).rgb, _ColorRampBlend);
    791. #endif
    792. #endif
    793. #if CHANGECOLOR_ON
    794. float3 currChangeColor = saturate(col.rgb);
    795. luminance = 0.3 * currChangeColor.r + 0.59 * currChangeColor.g + 0.11 * currChangeColor.b;
    796. luminance = saturate(luminance + _ColorChangeLuminosity);
    797. half3 dif = abs(currChangeColor - _ColorChangeTarget.rgb);
    798. col.rgb = lerp(col.rgb, half3(luminance, luminance, luminance) * _ColorChangeNewCol.rgb,
    799. max(sign(1 - saturate(dif.x + dif.y + dif.z) - _ColorChangeTolerance), 0.0));
    800. #if CHANGECOLOR2_ON
    801. dif = abs(currChangeColor - _ColorChangeTarget2.rgb);
    802. col.rgb = lerp(col.rgb, half3(luminance, luminance, luminance) * _ColorChangeNewCol2.rgb,
    803. max(sign(1 - saturate(dif.x + dif.y + dif.z) - _ColorChangeTolerance2), 0.0));
    804. #endif
    805. #if CHANGECOLOR3_ON
    806. dif = abs(currChangeColor - _ColorChangeTarget3.rgb);
    807. col.rgb = lerp(col.rgb, half3(luminance, luminance, luminance) * _ColorChangeNewCol3.rgb,
    808. max(sign(1 - saturate(dif.x + dif.y + dif.z) - _ColorChangeTolerance3), 0.0));
    809. #endif
    810. #endif
    811. #if POSTERIZE_ON && !POSTERIZEOUTLINE_ON
    812. col.rgb = pow(col.rgb, _PosterizeGamma) * _PosterizeNumColors;
    813. col.rgb = floor(col.rgb) / _PosterizeNumColors;
    814. col.rgb = pow(col.rgb, 1.0 / _PosterizeGamma);
    815. #endif
    816. #if HSV_ON
    817. half3 resultHsv = half3(col.rgb);
    818. half cosHsv = _HsvBright * _HsvSaturation * cos(_HsvShift * 3.14159265 / 180);
    819. half sinHsv = _HsvBright * _HsvSaturation * sin(_HsvShift * 3.14159265 / 180);
    820. resultHsv.x = (.299 * _HsvBright + .701 * cosHsv + .168 * sinHsv) * col.x
    821. + (.587 * _HsvBright - .587 * cosHsv + .330 * sinHsv) * col.y
    822. + (.114 * _HsvBright - .114 * cosHsv - .497 * sinHsv) * col.z;
    823. resultHsv.y = (.299 * _HsvBright - .299 * cosHsv - .328 * sinHsv) *col.x
    824. + (.587 * _HsvBright + .413 * cosHsv + .035 * sinHsv) * col.y
    825. + (.114 * _HsvBright - .114 * cosHsv + .292 * sinHsv) * col.z;
    826. resultHsv.z = (.299 * _HsvBright - .3 * cosHsv + 1.25 * sinHsv) * col.x
    827. + (.587 * _HsvBright - .588 * cosHsv - 1.05 * sinHsv) * col.y
    828. + (.114 * _HsvBright + .886 * cosHsv - .203 * sinHsv) * col.z;
    829. col.rgb = resultHsv;
    830. #endif
    831. #if OVERLAY_ON
    832. half4 overlayCol = tex2D(_OverlayTex, TRANSFORM_TEX(i.uv, _OverlayTex));
    833. overlayCol.rgb *= _OverlayColor.rgb * _OverlayGlow;
    834. #if !OVERLAYMULT_ON
    835. overlayCol.rgb *= overlayCol.a * _OverlayColor.rgb * _OverlayColor.a * _OverlayBlend;
    836. col.rgb += overlayCol;
    837. #else
    838. overlayCol.a *= _OverlayColor.a;
    839. col = lerp(col, col * overlayCol, _OverlayBlend);
    840. #endif
    841. #endif
    842. //OUTLINE-------------------------------------------------------------
    843. #if OUTBASE_ON
    844. #if OUTBASEPIXELPERF_ON
    845. half2 destUv = half2(_OutlinePixelWidth * _MainTex_TexelSize.x, _OutlinePixelWidth * _MainTex_TexelSize.y);
    846. #else
    847. half2 destUv = half2(_OutlineWidth * _MainTex_TexelSize.x * 200, _OutlineWidth * _MainTex_TexelSize.y * 200);
    848. #endif
    849. #if OUTDIST_ON
    850. i.uvOutDistTex.x += ((_Time + _RandomSeed) * _OutlineDistortTexXSpeed) % 1;
    851. i.uvOutDistTex.y += ((_Time + _RandomSeed) * _OutlineDistortTexYSpeed) % 1;
    852. #if ATLAS_ON
    853. i.uvOutDistTex = half2((i.uvOutDistTex.x - _MinXUV) / (_MaxXUV - _MinXUV), (i.uvOutDistTex.y - _MinYUV) / (_MaxYUV - _MinYUV));
    854. #endif
    855. half outDistortAmnt = (tex2D(_OutlineDistortTex, i.uvOutDistTex).r - 0.5) * 0.2 * _OutlineDistortAmount;
    856. destUv.x += outDistortAmnt;
    857. destUv.y += outDistortAmnt;
    858. #endif
    859. half spriteLeft = tex2D(_MainTex, i.uv + half2(destUv.x, 0)).a;
    860. half spriteRight = tex2D(_MainTex, i.uv - half2(destUv.x, 0)).a;
    861. half spriteBottom = tex2D(_MainTex, i.uv + half2(0, destUv.y)).a;
    862. half spriteTop = tex2D(_MainTex, i.uv - half2(0, destUv.y)).a;
    863. half result = spriteLeft + spriteRight + spriteBottom + spriteTop;
    864. #if OUTBASE8DIR_ON
    865. half spriteTopLeft = tex2D(_MainTex, i.uv + half2(destUv.x, destUv.y)).a;
    866. half spriteTopRight = tex2D(_MainTex, i.uv + half2(-destUv.x, destUv.y)).a;
    867. half spriteBotLeft = tex2D(_MainTex, i.uv + half2(destUv.x, -destUv.y)).a;
    868. half spriteBotRight = tex2D(_MainTex, i.uv + half2(-destUv.x, -destUv.y)).a;
    869. result = result + spriteTopLeft + spriteTopRight + spriteBotLeft + spriteBotRight;
    870. #endif
    871. result = step(0.05, saturate(result));
    872. #if OUTTEX_ON
    873. i.uvOutTex.x += ((_Time + _RandomSeed) * _OutlineTexXSpeed) % 1;
    874. i.uvOutTex.y += ((_Time + _RandomSeed) * _OutlineTexYSpeed) % 1;
    875. #if ATLAS_ON
    876. i.uvOutTex = half2((i.uvOutTex.x - _MinXUV) / (_MaxXUV - _MinXUV), (i.uvOutTex.y - _MinYUV) / (_MaxYUV - _MinYUV));
    877. #endif
    878. half4 tempOutColor = tex2D(_OutlineTex, i.uvOutTex);
    879. tempOutColor *= _OutlineColor;
    880. _OutlineColor = tempOutColor;
    881. #endif
    882. result *= (1 - originalAlpha) * _OutlineAlpha;
    883. half4 outline = _OutlineColor * i.color.a;
    884. outline.rgb *= _OutlineGlow;
    885. outline.a = result;
    886. #if ONLYOUTLINE_ON
    887. col = outline;
    888. #else
    889. col = lerp(col, outline, result);
    890. #endif
    891. #endif
    892. //-----------------------------------------------------------------------------
    893. #if FADE_ON
    894. half2 tiledUvFade1= TRANSFORM_TEX(i.uv, _FadeTex);
    895. half2 tiledUvFade2 = TRANSFORM_TEX(i.uv, _FadeBurnTex);
    896. #if ATLAS_ON
    897. tiledUvFade1 = half2((tiledUvFade1.x - _MinXUV) / (_MaxXUV - _MinXUV), (tiledUvFade1.y - _MinYUV) / (_MaxYUV - _MinYUV));
    898. tiledUvFade2 = half2((tiledUvFade2.x - _MinXUV) / (_MaxXUV - _MinXUV), (tiledUvFade2.y - _MinYUV) / (_MaxYUV - _MinYUV));
    899. #endif
    900. half fadeTemp = tex2D(_FadeTex, tiledUvFade1).r;
    901. half fade = smoothstep(_FadeAmount + 0.01, _FadeAmount + _FadeBurnTransition, fadeTemp);
    902. half fadeBurn = saturate(smoothstep(_FadeAmount - _FadeBurnWidth, _FadeAmount - _FadeBurnWidth + 0.1, fadeTemp) * _FadeAmount);
    903. col.a *= fade;
    904. _FadeBurnColor.rgb *= _FadeBurnGlow;
    905. col += fadeBurn * tex2D(_FadeBurnTex, tiledUvFade2) * _FadeBurnColor * originalAlpha * (1 - col.a);
    906. #endif
    907. #if SHADOW_ON
    908. half shadowA = tex2D(_MainTex, i.uv + half2(_ShadowX, _ShadowY)).a;
    909. half preMultShadowMask = 1 - (saturate(shadowA - col.a) * (1 - col.a));
    910. col.rgb *= 1 - ((shadowA - col.a) * (1 - col.a));
    911. col.rgb += (_ShadowColor * shadowA) * (1 - col.a);
    912. col.a = max(shadowA * _ShadowAlpha * i.color.a, col.a);
    913. #endif
    914. #if GLOW_ON
    915. half4 emission;
    916. #if GLOWTEX_ON
    917. emission = tex2D(_GlowTex, i.uv);
    918. #else
    919. emission = col;
    920. #endif
    921. col.rgb *= _GlowGlobal;
    922. emission.rgb *= emission.a * col.a * _Glow * _GlowColor;
    923. col.rgb += emission.rgb;
    924. #endif
    925. #if COLORRAMP_ON && COLORRAMPOUTLINE_ON
    926. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
    927. luminance = saturate(luminance + _ColorRampLuminosity);
    928. #if GRADIENTCOLORRAMP_ON
    929. col.rgb = lerp(col.rgb, tex2D(_ColorRampTexGradient, half2(luminance, 0)).rgb, _ColorRampBlend);
    930. #else
    931. col.rgb = lerp(col.rgb, tex2D(_ColorRampTex, half2(luminance, 0)).rgb, _ColorRampBlend);
    932. #endif
    933. #endif
    934. #if GREYSCALE_ON && GREYSCALEOUTLINE_ON
    935. luminance = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
    936. luminance = saturate(luminance + _GreyscaleLuminosity);
    937. col.rgb = lerp(col.rgb, half3(luminance, luminance, luminance) * _GreyscaleTintColor, _GreyscaleBlend);
    938. #endif
    939. #if POSTERIZE_ON && POSTERIZEOUTLINE_ON
    940. col.rgb = pow(col.rgb, _PosterizeGamma) * _PosterizeNumColors;
    941. col.rgb = floor(col.rgb) / _PosterizeNumColors;
    942. col.rgb = pow(col.rgb, 1.0 / _PosterizeGamma);
    943. #endif
    944. #if SHINE_ON
    945. half2 uvShine = uvRect;
    946. half cosAngle = cos(_ShineRotate);
    947. half sinAngle = sin(_ShineRotate);
    948. half2x2 rot = half2x2(cosAngle, -sinAngle, sinAngle, cosAngle);
    949. uvShine -= half2(0.5, 0.5);
    950. uvShine = mul(rot, uvShine);
    951. uvShine += half2(0.5, 0.5);
    952. half shineMask = tex2D(_ShineMask, i.uv).a;
    953. half currentDistanceProjection = (uvShine.x + uvShine.y) / 2;
    954. half whitePower = 1 - (abs(currentDistanceProjection - _ShineLocation) / _ShineWidth);
    955. col.rgb += col.a * whitePower * _ShineGlow * max(sign(currentDistanceProjection - (_ShineLocation - _ShineWidth)), 0.0)
    956. * max(sign((_ShineLocation + _ShineWidth) - currentDistanceProjection), 0.0) * _ShineColor * shineMask;
    957. #endif
    958. #if HOLOGRAM_ON
    959. half totalHologram = _HologramStripesAmount + _HologramUnmodAmount;
    960. half hologramYCoord = ((uvRect.y + (((_Time.x + _RandomSeed) % 1) * _HologramStripesSpeed)) % totalHologram) / totalHologram;
    961. hologramYCoord = abs(hologramYCoord);
    962. half alpha = RemapFloat(saturate(hologramYCoord - (_HologramUnmodAmount/totalHologram)), 0.0, 1.0, _HologramMinAlpha, saturate(_HologramMaxAlpha));
    963. half hologramMask = max(sign((_HologramUnmodAmount/totalHologram) - hologramYCoord), 0.0);
    964. half4 hologramResult = col;
    965. hologramResult.a *= lerp(alpha, 1, hologramMask);
    966. hologramResult.rgb *= max(1, _HologramMaxAlpha * max(sign(hologramYCoord - (_HologramUnmodAmount/totalHologram)), 0.0));
    967. hologramMask = 1 - step(0.01,hologramMask);
    968. hologramResult.rgb += hologramMask * _HologramStripeColor * col.a;
    969. col = lerp(col, hologramResult, _HologramBlend);
    970. #endif
    971. #if FLICKER_ON
    972. col.a *= saturate(col.a * step(frac(0.05 + (_Time.w + _RandomSeed) * _FlickerFreq), 1 - _FlickerPercent) + _FlickerAlpha);
    973. #endif
    974. col.a *= _Alpha;
    975. #if UNITY_UI_CLIP_RECT
    976. half2 clipMask = saturate((_ClipRect.zw - _ClipRect.xy - abs(i.mask.xy)) * i.mask.zw);
    977. col.a *= clipMask.x * clipMask.y;
    978. #endif
    979. #if UNITY_UI_ALPHACLIP
    980. clip (col.a - 0.001);
    981. #endif
    982. #if ALPHACUTOFF_ON
    983. clip((1 - _AlphaCutoffValue) - (1 - col.a) - 0.01);
    984. #endif
    985. #if ALPHAROUND_ON
    986. col.a = step(_AlphaRoundThreshold, col.a);
    987. #endif
    988. #if ALPHAOUTLINE_ON
    989. half alphaOutlineRes = pow(1 - col.a, max(_AlphaOutlinePower, 0.0001)) * step(_AlphaOutlineMinAlpha, col.a) * _AlphaOutlineBlend;
    990. col.rgb = lerp(col.rgb, _AlphaOutlineColor.rgb * _AlphaOutlineGlow, alphaOutlineRes);
    991. col.a = lerp(col.a, 1, alphaOutlineRes > 1);
    992. #endif
    993. col *= _Color;
    994. return col;
    995. }
    996. ENDCG
    997. }
    998. }
    999. CustomEditor "AllIn1SpriteShaderUiMaskMaterialInspector"
    1000. //Fallback "Sprites/Default" //Remove fallback so that any shader error is obvious to the user
    1001. }
    using System;
    using System.Collections.Generic;
    using System.Text;
    using JetBrains.Annotations;
    using UnityEngine;
    using UnityEngine.UI;
    
    [ExecuteInEditMode]
    public class ImageFlashEffect : MonoBehaviour
    {
        public Material Material ;
        public Texture  OverrideTexture;
    
        [Range(0.5f,5)]
        public float Scale = 1.0f;
        [Range(-180, 180)]
        public float Angle = 45f;
    
    
        //受Angle和Scale影响
        [Range(0.1f, 20)]
        public float Duration = 1;
    
        //受Angle和Scale影响
        [Range(0.1f, 20)]
        public float Interval = 3;
    
        //受Angle和Scale影响
        [Range(-10f, 10)]
        public float OffSet = 0;
    
        public Color Color = Color.white;
        [Range(1, 10)]
        public float Power = 1;
    
        private Material mDynaMaterial; 
        private MaskableGraphic mGraphic;
    
        private void Awake()
        {
            UpdateParam();
        }
    
        void UpdateParam()
        {
            if (Material == null)
            {
                Debug.LogWarning("Metarial is miss");
                return;
            }
    
            if (mGraphic == null)
            {
                mGraphic = GetComponent<MaskableGraphic>();
            }
    
            if (mGraphic is Text)
            {
                Debug.LogError("FlashEffec need component type of Image、RawImage");
                return;
            }
    
            if (mDynaMaterial == null)
            {
                mDynaMaterial = new Material(Material);
                mDynaMaterial.name = mDynaMaterial.name + "(Copy)";
                mDynaMaterial.hideFlags = HideFlags.DontSave | HideFlags.NotEditable;
            }
    
            if (mDynaMaterial == null)
            {
                return;
            }
    
            mDynaMaterial.mainTexture = null;
            if (OverrideTexture != null)
            {
                mDynaMaterial.mainTexture = OverrideTexture;
    
                if (mGraphic is RawImage)
                {
                    RawImage img = mGraphic as RawImage;
                    img.texture = null;
                }
                else if (mGraphic is Image)
                {
                    Image img = mGraphic as Image;
                    img.sprite = null;
                }
            }
            else
            {
                mDynaMaterial.mainTexture = mGraphic.mainTexture;
            }
    
            if (Duration > Interval)
            {
                Debug.LogWarning("ImageFlashEffect.UpdateParam:Duration need less Interval");
                Interval = Duration + 0.5f;
            }
    
            mDynaMaterial.SetColor("_LightColor", Color);
            mDynaMaterial.SetFloat("_LightPower", Power);
            mDynaMaterial.SetFloat("_LightScale", Scale);
            mDynaMaterial.SetFloat("_LightAngle", Angle);
            mDynaMaterial.SetFloat("_LightDuration", Duration);
            mDynaMaterial.SetFloat("_LightInterval", Interval);
            mDynaMaterial.SetFloat("_LightOffSetX", OffSet);
            mGraphic.material = mDynaMaterial;
            mGraphic.SetMaterialDirty();
        }
    
    #if UNITY_EDITOR
        void OnValidate()
        {
            UpdateParam();
        }
    #endif
    }
    

    20241016 UGUI的流光效果 - 图1

    Shader.rar

    https://github.com/mob-sakai/UIEffect

    20241016 UGUI的流光效果 - 图2