React Dither Background
React dithered background with Three.js rendering. Features wave patterns, Bayer matrix dithering, and retro pixelated aesthetics.
Building retro pixel art effects?
Join our Discord community for help from other developers working with Three.js rendering and dithering algorithms.
Ever wanted to recreate that nostalgic pixel art aesthetic you see in retro games, 8-bit graphics, or vintage computer displays? Those distinctive dithered patterns that use limited color palettes to create the illusion of complex gradients and textures? The way noise patterns blend with mathematical precision to simulate more colors than are actually available, creating that unmistakable retro computing charm? Most dithering effects use simple CSS filters or basic image processing, but they lack the sophisticated algorithms that create truly authentic pixel art visuals.
This React component creates that captivating dithered background using Three.js with post-processing effects, featuring procedural wave generation, Bayer matrix dithering algorithms, and authentic pixel art color quantization that brings vintage gaming aesthetics to your interface.
Dynamic dithered waves with authentic pixel art processing
Watch procedural wave patterns transform through mathematical dithering and color quantization:
Built for React applications with TypeScript and optimized Three.js rendering. Uses advanced GLSL shaders with Perlin noise algorithms and Bayer matrix dithering for authentic retro graphics while providing extensive controls for wave properties, color palettes, and pixel sizes. Perfect for retro gaming interfaces, pixel art applications, or any project needing that authentic 8-bit aesthetic.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/dither.json
npx shadcn@latest add https://www.shadcn.io/registry/dither.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/dither.json
bunx shadcn@latest add https://www.shadcn.io/registry/dither.json
Why simple CSS filters feel artificial
Developers create pixelated effects with CSS image-rendering or basic filters and consider them retro. Maybe they add some pixelated borders or color quantization. The problem? Basic CSS can't capture the complex, mathematically-driven nature of true dithering algorithms that emerge from color space quantization, noise pattern mathematics, and authentic pixel art techniques.
Three.js-based dithering with post-processing changes everything. It taps into the fundamental mathematics of computer graphics—the way Bayer matrices create ordered dithering, how color quantization reduces palettes, the organic beauty that emerges from Perlin noise and procedural generation. The algorithms use real dithering matrices and color space mathematics to create authentic retro computing experiences.
This component handles complex dithering mathematics automatically. Perlin noise generation, Bayer matrix calculations, color quantization algorithms, and post-processing effects all work together seamlessly. The result feels like viewing actual 8-bit graphics rendered in real-time.
Features
- Three.js rendering pipeline with React Three Fiber for optimized WebGL performance
- Procedural wave generation using multi-octave Perlin noise with fractal mathematics
- Bayer matrix dithering with authentic 8x8 ordered dithering algorithm implementation
- Color quantization system with configurable palette reduction and bit-depth control
- Mouse-responsive effects with interactive wave modulation and cursor tracking
- Post-processing pipeline with custom shader effects and render-to-texture workflows
- Configurable parameters with extensive control over waves, colors, and dithering
- Performance optimization with efficient shader compilation and Three.js context management
- Responsive design with automatic canvas scaling and device pixel ratio handling
- Memory management with proper Three.js cleanup and resource disposal
API Reference
Dither
Prop | Type | Default | Description |
---|---|---|---|
waveSpeed | number | 0.05 | Speed of wave animation |
waveFrequency | number | 3 | Frequency of noise pattern |
waveAmplitude | number | 0.3 | Amplitude of wave oscillation |
waveColor | [number, number, number] | [0.5, 0.5, 0.5] | RGB color values (0-1 range) |
colorNum | number | 4 | Number of colors in quantized palette |
pixelSize | number | 2 | Size of pixelated blocks |
disableAnimation | boolean | false | Pause wave animations |
enableMouseInteraction | boolean | true | Enable mouse-responsive effects |
mouseRadius | number | 1 | Radius of mouse influence |
className | string | - | Additional CSS classes |
...props | HTMLAttributes<HTMLDivElement> | - | All standard div props |
Color Palettes
Different color configurations for various retro aesthetics:
Palette | Colors | Description |
---|---|---|
Monochrome | 2-4 colors | Classic black and white pixel art |
CGA | 4 colors | IBM CGA computer graphics |
Game Boy | 4 colors | Nintendo Game Boy green palette |
NES | 8 colors | Nintendo Entertainment System |
Commodore 64 | 16 colors | Classic home computer palette |
Wave Patterns
Different parameter combinations for various visual effects:
Style | Speed | Frequency | Amplitude | Description |
---|---|---|---|---|
Gentle | 0.02 | 2 | 0.2 | Slow, subtle wave movement |
Standard | 0.05 | 3 | 0.3 | Balanced wave animation |
Active | 0.08 | 4 | 0.4 | Fast, dynamic patterns |
Chaotic | 0.1 | 6 | 0.6 | High-energy, complex waves |
Three.js architecture
Rendering Pipeline: Uses React Three Fiber with WebGL for efficient shader-based rendering, post-processing effects with EffectComposer, and optimized uniform management.
Shader Mathematics: Implements multi-octave Perlin noise using Taylor inverse square root and permutation functions for organic wave pattern generation with authentic mathematical noise.
Dithering Algorithm: Uses 8x8 Bayer matrix with ordered dithering mathematics, color quantization with bit reduction, and threshold-based pixel value assignments for authentic retro aesthetics.
Post-Processing Chain: Combines procedural wave generation with dithering effects through custom shader passes and render-to-texture workflows for seamless visual integration.
Performance considerations
Three.js Optimization: Uses efficient shader compilation with React Three Fiber optimizations, minimal uniform updates, and proper WebGL state management for consistent 60fps performance.
Shader Efficiency: Implements optimized GLSL code with reduced branching, efficient loop structures, and minimal texture lookups to reduce GPU computation overhead.
Memory Management: Properly handles Three.js resource lifecycle with automatic cleanup, canvas management, and effect disposal to prevent memory leaks during component unmounting.
Responsive Scaling: Uses device pixel ratio awareness with efficient canvas resizing and automatic viewport adjustments for optimal visual quality across display densities.
Common gotchas
Three.js Dependencies: Component requires Three.js and React Three Fiber ecosystem. Ensure proper version compatibility and SSR handling for Next.js applications.
Color Range: Wave colors should be in 0-1 range (not 0-255). Values outside this range may cause unexpected shader behavior or color clamping issues.
Performance Scaling: High pixel density combined with complex wave patterns can impact performance. Monitor frame rates when increasing visual complexity parameters.
WebGL Context: Component requires WebGL support for Three.js rendering. Gracefully handles context creation but won't render effects without WebGL capability.
Mouse Coordinates: Uses Three.js event system for consistent coordinate transformation across different canvas sizes and device pixel ratios.
Color Quantization: Low color numbers (colorNum < 3) may cause banding artifacts. Balance color reduction with visual quality for optimal retro aesthetics.
You might also like
Noise Background
Subtle texture patterns with grain effects
Faulty Terminal
Retro terminal effects with glitch aesthetics
Pixel Image
Pixelated image effects with retro processing
Retro Grid
Synthwave-style grid patterns with neon effects
Questions developers actually ask
React Dark Veil Background
React dark veil background with WebGL rendering. Features neural network-generated patterns, scanline effects, and customizable distortion using OGL.
React Interactive Dot Pattern
React dot pattern background with canvas rendering. Features interactive dots, inertia physics, proximity effects, and GSAP animations.