React Starry Planes Shaders
3D starry plane marching with ACES tonemapping and star-shaped patterns. Pure WebGL shaders for React with TypeScript and shadcn/ui—smooth GPU animations.
Building starry plane effects?
Join our Discord community for help from other developers working with WebGL shaders.
Look, we've all tried to build starry plane effects. You either end up with flat particle systems that look nothing like proper 3D star fields or JavaScript calculations that can't handle multiple layered planes smoothly. This React component uses advanced WebGL plane marching with ACES tonemapping that actually runs at 60fps without melting your CPU.
Smooth starry planes animation
Mesmerizing 3D star field with layered planes and organic movement that won't destroy your performance metrics:
Created by mrange in 2024-08-07
Built for React applications with TypeScript and Next.js in mind. The animation runs entirely on the GPU using WebGL plane marching with Inigo Quilez's star distance functions and ACES tonemapping. Works seamlessly with shadcn/ui design systems.
Installation
npx shadcn@latest add https://www.shadcn.io/registry/starry-planes-shaders.json
npx shadcn@latest add https://www.shadcn.io/registry/starry-planes-shaders.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/starry-planes-shaders.json
bunx shadcn@latest add https://www.shadcn.io/registry/starry-planes-shaders.json
Usage
import { StarryPlanesShaders } from "@/components/ui/starry-planes-shaders";
export default function Hero() {
return (
<StarryPlanesShaders>
<div className="relative z-10">
<h1>Your content here</h1>
</div>
</StarryPlanesShaders>
);
}
Why most starry plane implementations suck
Most developers try to animate star fields with CSS 3D transforms or Three.js particle systems. Bad idea. You're dealing with hundreds of DOM elements or draw calls, complex z-ordering, and wondering why your React app feels sluggish. Some use canvas drawing with JavaScript star calculations, which sounds smart until you realize you're computing positions for every star on every frame.
This React component uses mathematical plane marching with star-shaped distance functions and ACES tonemapping. The GPU handles everything using optimized layered plane rendering with organic camera movement. No JavaScript calculations, no draw calls, just smooth 60fps mathematical 3D star fields.
Features
- Zero JavaScript animation overhead - Pure WebGL plane marching runs on GPU
- ACES tonemapping with professional color grading for realistic star brightness
- Star distance functions from Inigo Quilez for mathematically perfect star shapes
- TypeScript definitions for proper IDE support in React projects
- Customizable parameters with 4 props for complete control
- Performance optimization through efficient plane marching loops
- shadcn/ui compatible for consistent design systems
- Responsive design with automatic canvas resizing
API Reference
StarryPlanesShaders
Main container component for the starry planes effect.
Prop | Type | Default | Description |
---|---|---|---|
speed | number | 1.0 | Animation speed multiplier (0.1 to 3.0) |
planeDist | number | 0.5 | Distance between star planes (0.1 to 1.0) |
furthest | number | 16.0 | Maximum plane rendering distance (8.0 to 32.0) |
fadeFrom | number | 8.0 | Distance where fading begins (4.0 to 16.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 plane marching shaders. Consider reducing the furthest prop (try 8.0-12.0) or lowering speed for better performance.
Stars appear too dense/sparse: Adjust the planeDist
prop. Lower values (0.2-0.3) create denser star fields, higher values (0.7-1.0) create more spread out planes.
Fading looks abrupt: Use the fadeFrom
prop to control where star fading begins. Values closer to furthest
create smoother transitions.
Camera movement too fast: Lower the speed
prop for more controlled movement. Values around 0.3-0.5 work well for background effects.
You might also like
Explore other shader-based background components for React applications:
Raymarching Shaders
Advanced 3D tunnel effects with ACES tonemapping
Sphere Field Shaders
3D sphere field raymarching with organic distortion
Nebula Shaders
Cosmic nebula patterns with deep space aesthetics
Matrix Shaders
Digital rain effects with cyberpunk styling
Cosmic Waves Shaders
Ethereal wave patterns with cosmic color palettes
Digital Tunnel Shaders
Futuristic tunnel effects with neon lighting
Questions developers actually ask
React Sphere Field Shaders
3D sphere field raymarching with spherical projection and organic distortion. Pure WebGL shaders for React with TypeScript and shadcn/ui—smooth GPU animations.
Synthwave Canyon Shaders
Retro synthwave landscape with neon colors and procedural terrain. Plane marching algorithm creating nostalgic 80s canyon flythrough with dynamic sun effects.