React 2D Noise Contours
Smooth fractal contour lines with numerical gradients on 2D simplex noise. Pure WebGL contour mapping for React with TypeScript and shadcn/ui—topographic beauty meets performance.
Building contour mapping effects?
Join our Discord community for help from other developers working with WebGL shaders.
Creating smooth contour lines from noise functions is notoriously difficult due to aliasing artifacts. Most approaches either produce jagged edges or require expensive anti-aliasing. This React component uses numerical gradients and advanced smoothing techniques to create beautiful, smooth contour lines from 2D simplex noise that render perfectly at any scale.
Smooth anti-aliased contours
Beautiful 2D noise contour patterns with smooth fractal lines and gradient-based anti-aliasing:
Created by Shane in 2015-12-17
Built for React applications with TypeScript and Next.js in mind. The animation runs entirely on the GPU using WebGL with 2D simplex-based noise, numerical gradient calculations, and sophisticated anti-aliasing. Works seamlessly with shadcn/ui design systems.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/2d-noise-contours-shaders.json
npx shadcn@latest add https://www.shadcn.io/registry/2d-noise-contours-shaders.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/2d-noise-contours-shaders.json
bunx shadcn@latest add https://www.shadcn.io/registry/2d-noise-contours-shaders.json
Usage
import { TwoDNoiseContoursShaders } from "@/components/ui/2d-noise-contours-shaders";
export default function Hero() {
return (
<TwoDNoiseContoursShaders>
<div className="relative z-10">
<h1>Your content here</h1>
</div>
</TwoDNoiseContoursShaders>
);
}
Why most contour implementations fail
Most developers try to create contour lines using simple fract()
operations on noise functions. Terrible approach. You get severe aliasing artifacts that look pixelated and jagged, especially when zooming or animating. Traditional anti-aliasing methods are either too expensive or don't work well with procedural content.
This React component uses numerical gradient calculations combined with distance-based smoothing functions. The GPU handles everything using optimized 2D simplex noise with smooth fractal operations and gradient-aware anti-aliasing. No aliasing artifacts, no expensive MSAA, just mathematically perfect contour lines at 60fps.
Features
- Zero aliasing artifacts - Numerical gradient-based anti-aliasing produces smooth contour lines
- 2D simplex-based noise using custom simplesque algorithm for artifact-free patterns
- Smooth fractal operations with multiple noise octaves for natural complexity
- Gradient-aware smoothing using distance estimation techniques for perfect edge quality
- TypeScript definitions for proper IDE support in React projects
- Customizable parameters with 5 props for complete contour control
- Performance optimization through efficient GPU-based noise generation
- shadcn/ui compatible for consistent design systems
- Responsive design with automatic canvas resizing
API Reference
TwoDNoiseContoursShaders
Main container component for the 2D noise contour effect.
Prop | Type | Default | Description |
---|---|---|---|
speed | number | 1.0 | Animation speed multiplier (0.1 to 3.0) |
scale | number | 1.0 | Noise scale factor (0.1 to 5.0) |
contours | number | 6.0 | Number of contour lines (2.0 to 20.0) |
colorIntensity | number | 1.0 | Color band intensity (0.0 to 2.0) |
highlightStrength | number | 1.0 | Gradient highlight strength (0.0 to 3.0) |
className | string | - | Additional Tailwind CSS classes |
...props | HTMLAttributes<HTMLDivElement> | - | All standard div props |
Common gotchas
Contour lines appear jagged: The anti-aliasing system requires WebGL with proper gradient support. Check that your browser supports the necessary WebGL extensions.
Performance issues on mobile: Numerical gradient calculations are GPU-intensive. Consider reducing contours
count and scale
for better mobile performance.
Colors too vibrant/muted: Adjust colorIntensity
to control the strength of the red and blue color bands. Set to 0 for pure grayscale contours.
Missing detail in highlights: Increase highlightStrength
to enhance the gradient-based highlighting that shows the noise structure beneath the contours.
Animation too fast/slow: The speed
parameter affects both the noise animation and color cycling. Reduce for slower, more contemplative movement.
You might also like
Explore other shader-based background components for React applications:
Smooth Noise Contours
3D noise contours with advanced gradient smoothing
Smooth Voronoi Contours
Voronoi cellular patterns with smooth contour lines
3-Tap Voronoi Shaders
Ultra-fast 3-tap Voronoi with simplex grid and highlights
Cellular Tiled Tunnel
Raymarched 2nd-order Voronoi tunnel with 3D cellular tiling
Perspex Web Lattice
Raymarched Voronoi lattice with perspex-like materials
Abstract Mod Shaders
3D abstract raymarching with mathematical patterns
Questions developers actually ask
React Shader Components
React shader components with GPU effects and fragment shaders. TypeScript patterns for Next.js with react-shaders and shadcn/ui.
React Abstract Mod Shaders
3D abstract raymarching with procedural geometry and atmospheric effects. Pure WebGL shaders for React with TypeScript and shadcn/ui—smooth GPU animations.