advanced

#31 Health Bar

Animated health bar with damage feedback

Health bars are a staple game UI element. This shader builds one entirely on the GPU using a rounded rectangle SDF for the bar shape, with a fill level that oscillates via sin(iTime). The fill color transitions from green through yellow to red as health drops. A damage flash fires white when health decreases, and a pulsing warning activates below 25%. Tick marks at each quarter provide visual reference.

Key Concepts

Try this shader live in the Shader Sandbox editor with real-time preview.
Open in Sandbox

Source Code


    
← Previous FBM Terrain Next → Dissolve Effect

All Tutorials