Join our Discord Community

React Orb Background

React orb background with WebGL shader animation. Features dynamic hue shifting, mouse-responsive hover effects, and organic noise-based morphing for mystical interfaces.

Powered by

Creating mystical orb effects?

Join our Discord community for help from other developers working with WebGL shaders and organic animations.


Ever gazed at mystical orbs in fantasy games and wondered how to create that mesmerizing, organic energy that seems to pulse with life? Those ethereal spheres that shift and morph through colors, responding to your presence with liquid-like distortions and gentle rotations? The way they combine noise patterns with mathematical precision to create something that feels both artificial and alive? Most visual effects rely on pre-rendered animations or simple CSS gradients, but they lack the dynamic responsiveness that makes truly magical interfaces.

This React component creates that captivating orb effect using WebGL shaders with OGL library, featuring dynamic hue shifting, organic noise morphing, and mouse-responsive interactions that bring mystical energy to your interface.

Dynamic orb with organic noise morphing

Watch the orb pulse and respond with fluid color transitions and hover distortions:

Loading component...

Built for React applications with TypeScript and optimized WebGL rendering. Uses advanced GLSL shaders for organic noise generation while providing intuitive controls for hue shifting, hover intensity, and rotation behaviors. Perfect for gaming interfaces, mystical themes, or any application needing that magical orb presence.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/orb.json
npx shadcn@latest add https://www.shadcn.io/registry/orb.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/orb.json
bunx shadcn@latest add https://www.shadcn.io/registry/orb.json

Why static orbs feel lifeless

Developers create circular gradients with CSS and consider them orbs. Maybe they add some basic animations or color transitions. The problem? Static gradients can't capture the organic, living quality of truly dynamic energy orbs that feel like they have consciousness.

Shader-based orbs with WebGL change everything. They tap into our fascination with energy and magic—the way organic patterns flow naturally, how colors blend in impossible ways, the hypnotic movement that suggests inner life. The mathematical algorithms use 3D noise functions and color space manipulation to create truly organic visual experiences.

This component handles complex shader mathematics automatically. Perlin noise generation, YIQ color space conversion, alpha extraction, and lighting calculations all work together seamlessly. The result feels like summoning actual mystical energy on your screen.

Features

  • WebGL shader rendering with advanced GLSL for high-performance organic animations
  • Dynamic hue shifting using YIQ color space for natural color transitions
  • Organic noise morphing with 3D Perlin noise for natural, flowing boundaries
  • Mouse-responsive hover effects with proximity detection and smooth distortion
  • Rotation controls with configurable rotation speed and hover-based triggering
  • Multi-layered lighting combining distance-based and inverse-square light models
  • Alpha blending with custom alpha extraction for proper transparency handling
  • Color customization through hue parameter supporting full color spectrum
  • Performance optimization with efficient WebGL context management and cleanup
  • Responsive canvas with automatic device pixel ratio handling

API Reference

Orb

PropTypeDefaultDescription
huenumber0Hue shift in degrees (0-360)
hoverIntensitynumber0.2Distortion intensity on hover (0-1)
rotateOnHoverbooleantrueEnable rotation when hovering
forceHoverStatebooleanfalseForce permanent hover effect
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All standard div props

Hue Values

Different hue settings for various color themes:

HueColorTheme
0Purple/PinkDefault mystical
60Yellow/OrangeFire energy
120GreenNature/poison
180Cyan/BlueIce/water
240Blue/PurpleElectric/storm
300Magenta/PurpleDark magic

Hover Intensity Levels

Different intensity settings for interaction feedback:

IntensityEffectUse Case
0.1SubtleMinimal distraction
0.2StandardBalanced interaction
0.3NoticeableClear feedback
0.5StrongDramatic response
1.0MaximumExtreme distortion

Shader mathematics

Perlin Noise Generation: Uses 3D simplex noise with hash functions and interpolation to create organic, flowing boundaries that morph naturally over time.

YIQ Color Space: Converts between RGB and YIQ color spaces for natural hue shifting that preserves luminance while rotating through color wheel.

Light Model Combination: Combines linear attenuation (1/(1+d*a)) and inverse-square (1/(1+d²*a)) lighting for realistic energy falloff with artistic control.

Alpha Extraction: Custom algorithm that extracts alpha from color intensity, enabling proper transparency blending without pre-multiplied alpha artifacts.

Performance considerations

WebGL Context Management: Efficiently manages WebGL context with proper cleanup and lost context handling to prevent memory leaks.

Shader Compilation: Compiles vertex and fragment shaders once during initialization, then reuses compiled programs for optimal performance.

Uniform Updates: Updates only necessary uniforms each frame, avoiding expensive state changes and maintaining consistent 60fps rendering.

Canvas Sizing: Handles device pixel ratio automatically for crisp rendering on high-DPI displays while maintaining performance.

Common gotchas

WebGL Support: Component requires WebGL-enabled browser. Gracefully handles initialization failures but won't render without WebGL support.

Container Dimensions: Component fills its container completely. Ensure parent element has defined width and height for proper orb rendering.

Mouse Coordinate System: Uses normalized UV coordinates for consistent hover detection across different container sizes and device pixel ratios.

Hue Range: Hue values outside 0-360 range will wrap around due to circular nature of color wheel. Negative values work but may be confusing.

Context Loss: WebGL contexts can be lost on mobile or during high memory usage. Component handles this with proper cleanup and reinitialization.

Animation Performance: Continuously running animation loop may impact battery life on mobile. Consider pausing animation when not visible.

You might also like

Questions developers actually ask