⏱ 1 min read
Glitch Shader
A UI glitch shader implemented with a 3-layer combination of RGB Split, texture-based UV distortion, and Mask layers

UI Glitch Shader
Implementation
- 01
RGB Split (chromatic aberration)
Sample only the R and B channels offset in each direction → G stays at the original. If the offset is 0, no branching — same as the original.
- 02
2. Discrete time stepping (choppy glitch feel)
floorquantizes time into steps so UV jumps abruptly → an analog tape glitch feel. - 03
3. Texture × Texture UV distortion
GlitchTexture (spatial pattern) × WiggleTexture (temporal variation) → swapping the two textures gives a completely different pattern.
- 04
4. Branchless Mask (Flip Blink + RGB Channel Cycle)
Handled with step/lerp combinations, no GPU branches.
#pragma target 2.0Mobile target — branching cost minimized.
Tradeoffs & Future Work
Tradeoffs
- Up to 4 texture samples (Main×3 + Glitch + Wiggle + Mask) — overkill for simple UI, so usage must be limited
- No early-z benefit due to discard — pixels with mask 0 are explicitly discarded // however, this project uses no MSAA and uses FXAA
Future Work
- Atlas support — added ST transform so GlitchTexture / WiggleTexture can be sliced and used from a Sprite Atlas