React Perspex Web Lattice
Raymarched Voronoi lattice with perspex-like materials and edge detection. Pure WebGL geometric patterns for React with TypeScript and shadcn/ui—smooth GPU crystalline structures.
Building geometric lattice effects?
Join our Discord community for help from other developers working with WebGL shaders.
Look, we've all tried to build crystalline lattice structures. You either end up with basic CSS grid patterns that look nothing like proper geometric materials or complex 3D models that can't handle Voronoi calculations smoothly. This React component uses advanced WebGL raymarching with 2nd-order Voronoi patterns and edge detection that actually runs at 60fps without melting your CPU.
Smooth perspex lattice animation
Mesmerizing raymarched Voronoi lattice with perspex-like materials and geometric edge detection that won't destroy your performance metrics:
Created by Shane in 2016-07-06
Built for React applications with TypeScript and Next.js in mind. The animation runs entirely on the GPU using WebGL raymarching with 2nd-order Voronoi calculations, geometric edge detection, and realistic material properties. Works seamlessly with shadcn/ui design systems.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/perspex-web-lattice-shaders.json
npx shadcn@latest add https://www.shadcn.io/registry/perspex-web-lattice-shaders.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/perspex-web-lattice-shaders.json
bunx shadcn@latest add https://www.shadcn.io/registry/perspex-web-lattice-shaders.json
Usage
import { PerspexWebLatticeShaders } from "@/components/ui/perspex-web-lattice-shaders";
export default function Hero() {
return (
<PerspexWebLatticeShaders>
<div className="relative z-10">
<h1>Your content here</h1>
</div>
</PerspexWebLatticeShaders>
);
}
Why most lattice implementations suck
Most developers try to create geometric lattices with CSS grids or basic WebGL. Bad idea. You're dealing with unrealistic flat patterns, poor material simulation, and wondering why your React app feels sluggish. Some use Three.js with complex geometries, which sounds smart until you realize you're computing thousands of triangles for mathematical patterns.
This React component uses raymarched 2nd-order Voronoi with authentic perspex material simulation and geometric edge detection. The GPU handles everything using optimized distance field operations with realistic lighting and environmental reflections. No JavaScript calculations, no geometry overhead, just smooth 60fps mathematical lattice rendering.
Features
- Zero JavaScript lattice overhead - Pure WebGL raymarching runs on GPU
- 2nd-order Voronoi generation with sophisticated hash functions for authentic cell patterns
- Geometric edge detection integrated with normal calculations for enhanced visual definition
- Perspex material simulation with realistic transparency and reflection properties
- TypeScript definitions for proper IDE support in React projects
- Customizable parameters with 4 props for complete lattice control
- Performance optimization through efficient raymarching algorithms
- shadcn/ui compatible for consistent design systems
- Responsive design with automatic canvas resizing
API Reference
PerspexWebLatticeShaders
Main container component for the perspex web lattice effect.
Prop | Type | Default | Description |
---|---|---|---|
speed | number | 1.0 | Animation speed multiplier (0.1 to 3.0) |
rotationSpeed | number | 1.0 | Canvas rotation speed (0.1 to 3.0) |
latticeScale | number | 1.0 | Voronoi cell scale factor (0.5 to 3.0) |
edgeIntensity | number | 1.0 | Edge detection intensity (0.1 to 3.0) |
className | string | - | Additional Tailwind CSS classes |
...props | HTMLAttributes<HTMLDivElement> | - | All standard div props |
Common gotchas
Animation not working: WebGL might not be supported in the browser. The component logs warnings when WebGL initialization fails. Check browser compatibility.
Performance issues on mobile: Some older phones struggle with complex raymarching and Voronoi calculations. Consider reducing speed and latticeScale props for better performance.
Lattice too fine/coarse: Adjust the latticeScale
prop to control Voronoi cell size. Lower values create finer patterns, higher values create larger geometric cells.
Rotation too fast/slow: Use the rotationSpeed
prop to control canvas rotation. Values around 0.5-0.7 work well for subtle environmental movement.
Edges too harsh/soft: Lower the edgeIntensity
prop for softer edge detection. Values around 0.3-0.7 create subtle geometric definition without visual noise.
You might also like
Explore other shader-based background components for React applications:
Oldschool Tube Shaders
Classic cylindrical tunnel effect with Voronoi patterns
Cosmic Waves Shaders
Ethereal wave patterns with cosmic color palettes
Sphere Field Shaders
3D sphere field raymarching with organic distortion
Abstract Mod Shaders
3D abstract raymarching with mathematical patterns
Raymarching Shaders
Advanced 3D raymarching with ACES tonemapping
Nebula Shaders
Cosmic nebula patterns with deep space aesthetics
Questions developers actually ask
React Oldschool Tube Shaders
Classic cylindrical tunnel effect with Voronoi patterns and bump mapping. Pure WebGL retro tunnel for React with TypeScript and shadcn/ui—smooth GPU oldschool vibes.
React Plasma Shaders
React plasma effect with GPU energy patterns. Organic plasma animations for Next.js with TypeScript and shadcn/ui—free code.