An interactive 3D jelly slider visualization powered by WebGPU and TypeGPU, featuring GPU-accelerated ray marching, physics simulation, and advanced rendering techniques.
- GPU Ray Marching: Real-time signed distance field (SDF) rendering with ray marching
- Physics Simulation: Position-based dynamics with Verlet integration for realistic jelly behavior
- Advanced Rendering:
- Fresnel reflection and refraction
- Beer-Lambert light absorption
- Temporal anti-aliasing (TAA)
- Ambient occlusion
- Caustic lighting effects
- Interactive Controls: Drag the jelly slider to interact with the physics simulation
- Responsive Quality: Auto-adjusts rendering quality based on GPU performance
- Modern browser with WebGPU support (Chrome 113+, Edge 113+)
- GPU with WebGPU capabilities
npm installStart the development server:
npm run devThe application will open at http://localhost:3000
Build for production:
npm run buildPreview the production build:
npm run previewjelly/
├── src/
│ ├── index.ts # Main application entry point with ray marching shaders
│ ├── slider.ts # Physics-based slider implementation
│ ├── camera.ts # Camera controller with TAA jitter
│ ├── events.ts # Mouse/touch event handling
│ ├── taa.ts # Temporal anti-aliasing resolver
│ ├── utils.ts # Rendering utilities (Fresnel, Beer-Lambert, etc.)
│ ├── dataTypes.ts # TypeGPU data structures and layouts
│ ├── constants.ts # Rendering and physics constants
│ └── numbers.ts # Percentage text rendering system
├── index.html # HTML entry point
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── vite.config.ts # Vite build configuration
- TypeGPU: Type-safe WebGPU shader programming in TypeScript
- Vite: Fast development server and build tool
- wgpu-matrix: Efficient matrix operations for WebGPU
- @typegpu/sdf: Signed distance field utilities
- @typegpu/noise: Noise and pseudo-random functions
The renderer uses sphere tracing to march rays through the scene, evaluating signed distance functions (SDFs) to determine surface intersections with sub-pixel accuracy.
The jelly slider uses position-based dynamics with:
- Verlet integration for stable physics
- Distance constraints for segment length preservation
- Bending resistance with variable stiffness
- Compression-based arching behavior
- Ray marching with SDF evaluation
- Normal calculation using gradient estimation
- Lighting with shadows and ambient occlusion
- Fresnel-based reflection/refraction mixing
- Temporal anti-aliasing for smooth motion
- Mouse/Touch Drag: Interact with the jelly slider
- The percentage display updates based on slider position
Based on the TypeGPU jelly-slider example
Original implementation from the TypeGPU project by Software Mansion.