Join our Discord Community

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.

Powered by

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:

Loading component...

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.

PropTypeDefaultDescription
speednumber1.0Animation speed multiplier (0.1 to 3.0)
scalenumber1.0Noise scale factor (0.1 to 5.0)
contoursnumber6.0Number of contour lines (2.0 to 20.0)
colorIntensitynumber1.0Color band intensity (0.0 to 2.0)
highlightStrengthnumber1.0Gradient highlight strength (0.0 to 3.0)
classNamestring-Additional Tailwind CSS classes
...propsHTMLAttributes<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:

Questions developers actually ask