Granular Sand Physics Simulator. in 3D
Curated 3D Web Creative Coding project by @SamGCoder • 2026-09-14
3D Graphics & Rendering Pipeline
State-of-the-art WebGPU rendering engine delivering high compute shader throughput, reduced CPU overhead, and native multi-pass buffer rendering.
Physics & Dynamic Simulation
Interactive real-time physics engine integration featuring collision detection, rigid body kinematics, and smooth motion damping.
Real-time Performance & Polish
60+ FPS browser execution with instanced rendering, memory-managed geometry buffers, and seamless responsive viewport scaling across desktop and mobile devices.
Aesthetic & Creation Overview
Developer SamG open-sources GRAIN, a granular sand physics simulator. Transpiling CUDA simulation kernels directly into WGSL compute shaders executed over WebGPU pipelines, it simulates 131,072 individual sand particles in real time—featuring hourglass funnels, dune collapse angles, pipe flow, and cursor turbulence stirring. An outstanding GPGPU benchmark demonstrating real-time granular physics in the browser.
Developer Architecture & AI Prompt Engineering Guide
To study or reproduce this 3D web experience with modern AI coding assistants (Claude Code, Cursor, Codex):
# Recommended AI Prompt Template:
"Create an interactive Three.js 3D web experience based on 'Granular Sand Physics Simulator. in 3D'. Implement an antialiased WebGLRenderer with tone mapping, an OrbitControls camera with smooth damping, dynamic lighting with soft shadow mapping, and responsive resize handling. Optimize with InstancedMesh and clean render loops."
- DevTools Shader & Draw Call Inspection: Press F12 on the demo page to inspect WebGL draw calls, shader programs, and buffer allocations.
- Creator Devlogs: Follow @SamGCoder on X for ongoing 3D graphics updates, procedural workflows, and code snippets.
Related 3D Showcases
Explore more interactive Three.js experiments, WebGL shaders, and creative coding
Dan Greenheck Open-sources Three.js Particle Fluids, an Exceptional
Dan Greenheck open-sources Three.js Particle Fluids, an exceptional WebGPU-accelerated physics engine. Harnessing native compute shaders, it delivers real-time SPH fluid dynamics, rigid-body collisions, soft-body viscoelastic solvers, and dynamic cloth tearing in the browser, complete with live interactive demos and full source code on GitHub.
Creative Coder Scott Releases an Interactive Sand Sandbox in 3D
Creative coder Scott releases an interactive sand sandbox toy powered by Three.js and WebGPU compute shaders. Supporting responsive multi-touch gestures on mobile and tablet displays, users' fingers carve silky granular waves through dynamic sandbanks that collapse realistically according to physical friction angles. An impressive demonstration of parallel granular particle physics running smoothly on mobile hardware via WebGPU.
Shaders - Interactive 3D GitHub Showcase
Interactive 3D web experience and WebGL creative coding demonstration by @shaders.
OptiJuegos: DirectX 9 to WebGPU Graphics Port
Ranked as the top technical showcase of the week, OptiJuegos presents an experimental port of native DirectX 9 graphics pipelines over to WebGPU, exploring legacy shader translation, draw call batching, and high-performance browser execution.