Join our Discord Community

React Fiber Waves Background

React fiber waves background with WebGL shaders. Features flowing wave lines, Perlin noise algorithms, and mouse interaction.

Powered by

Creating flowing visual effects?

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


Ever wanted to recreate those mesmerizing fiber optic waves you see in data visualizations, audio reactive displays, or flowing abstract backgrounds? Those organic wave patterns that seem to pulse with life, creating depth and movement through mathematical precision? The way multiple lines flow in harmony, each following its own path yet contributing to a cohesive visual symphony? Most wave effects rely on simple CSS animations or basic particle systems, but they lack the sophisticated noise algorithms that create truly organic flowing patterns.

This React component creates that captivating fiber wave effect using WebGL shaders with OGL library, featuring Perlin noise-based wave generation, smooth mouse interaction, and mathematical line rendering that brings flowing energy to your interface.

Dynamic fiber optic waves with smooth interaction

Watch flowing wave lines pulse and respond with mathematical precision and cursor sensitivity:

Loading component...

Built for React applications with TypeScript and optimized WebGL rendering. Uses advanced GLSL shaders with Perlin noise algorithms for authentic organic wave generation while providing intuitive controls for amplitude, spacing, and color intensity. Perfect for data visualization interfaces, audio-reactive applications, or any project needing that flowing fiber optic aesthetic.

Installation

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

Why simple CSS animations feel artificial

Developers create wave effects with CSS keyframes and consider them organic. Maybe they add some basic transform animations or linear wave functions. The problem? Simple CSS animations can't capture the complex, noise-based nature of true fiber optic flow that emerges from mathematical noise functions and shader-based rendering.

Shader-based fiber waves with WebGL changes everything. It taps into the fundamental mathematics of Perlin noise—the way random gradients create organic patterns, how mathematical functions generate smooth wave flows, the hypnotic beauty that emerges from layered line rendering. The algorithms use real Perlin noise calculations and distance field mathematics to create authentic flowing effects.

This component handles complex shader mathematics automatically. Perlin noise generation, smooth line rendering, mouse coordinate transformation, and wave amplitude calculations all work together seamlessly. The result feels like watching actual fiber optic data streams through your screen.

Features

  • WebGL shader rendering with advanced GLSL for real-time wave line generation
  • Perlin noise algorithms using mathematical gradient functions for organic wave patterns
  • Dynamic line system with 40+ flowing lines at different depths and amplitudes
  • Mouse-responsive interaction with smooth coordinate tracking and wave modulation
  • Mathematical wave functions using smoothstep and distance field calculations
  • Configurable wave properties with precise control over amplitude, distance, and color
  • Performance optimization with WebGL context management and efficient rendering
  • Responsive design with automatic canvas scaling and device pixel ratio handling
  • Memory management with proper WebGL context disposal and resource cleanup
  • Alpha blending support for seamless integration with various backgrounds

API Reference

FiberWaves

PropTypeDefaultDescription
color[number, number, number][1, 1, 1]RGB color values (0-1 range)
amplitudenumber1Wave amplitude multiplier
distancenumber0Wave line vertical separation
enableMouseInteractionbooleanfalseEnable mouse-responsive effects
classNamestring-Additional CSS classes
...propsHTMLAttributes<HTMLDivElement>-All standard div props

Color Configurations

Different color schemes for various visual themes:

ThemeColor ValuesEffect
White[1, 1, 1]Pure white fiber lines
Cyan[0, 1, 1]Electric blue-cyan glow
Magenta[1, 0, 1]Purple-pink energy lines
Purple[0.8, 0.4, 1]Soft purple gradient
Orange[1, 0.5, 0]Warm orange fiber glow

Wave Settings

Different amplitude and distance combinations for various effects:

EffectAmplitudeDistanceDescription
Subtle0.50Gentle, minimal wave motion
Standard1.00Balanced wave animation
Dynamic1.50.2Active, separated lines
Intense2.00.5Strong, dramatic waves

Shader mathematics

Perlin Noise Generation: Implements mathematical Perlin noise using gradient vectors and smooth interpolation functions to create organic, non-repeating wave patterns.

Distance Field Rendering: Uses smoothstep functions and distance calculations to create smooth line edges with anti-aliasing and blur effects for professional visual quality.

Wave Function Composition: Combines multiple noise octaves with time-based phase shifting to create complex, layered wave patterns that feel natural and organic.

Mouse Integration: Transforms screen coordinates to normalized UV space with smooth interpolation for consistent interaction across different container sizes.

Performance considerations

WebGL Optimization: Uses efficient GLSL shader compilation with optimized uniform updates and minimal state changes for consistent 60fps performance.

Fragment Shader Efficiency: Implements mathematical optimizations including loop unrolling and function inlining to reduce GPU computation overhead for real-time rendering.

Memory Management: Properly handles WebGL context creation, canvas management, and resource disposal to prevent memory leaks and context loss.

Responsive Scaling: Uses device pixel ratio awareness with efficient canvas resizing to maintain crisp visuals across different screen densities.

Common gotchas

WebGL Context: Component requires WebGL-enabled browser. Gracefully handles context creation failures but won't render without WebGL support.

Color Range: Color values should be in 0-1 range (not 0-255). Values outside this range may cause unexpected shader behavior or color clamping.

Performance Impact: Continuous shader execution can impact battery life on mobile devices. Consider pausing animation when component is not visible.

Container Sizing: Component fills its container completely. Ensure parent element has defined dimensions for proper wave pattern rendering.

Mouse Coordinates: Uses normalized UV coordinates for consistent behavior across different container sizes and device pixel ratios.

Amplitude Limits: Very high amplitude values (>5) may cause visual artifacts or clipping. Keep amplitude values reasonable for smooth wave animation.

You might also like

Questions developers actually ask