https://github.com/wesfly/wgpu-raymarcher
A real-time interactive raymarching renderer built with Rust and WGPU. Renders 3D scenes using distance fields instead of traditional polygons, featuring dynamic lighting, shadows, reflections, and materials. Demonstrates advanced GPU rendering techniques with interactive camera controls and animated objects.
https://github.com/wesfly/wgpu-raymarcher
distance-fields graphics graphics-programming raymarching raymarching-distance-fields raymarching-shader rust sdf wgpu wgpu-rs wgpuengine
Last synced: 9 months ago
JSON representation
A real-time interactive raymarching renderer built with Rust and WGPU. Renders 3D scenes using distance fields instead of traditional polygons, featuring dynamic lighting, shadows, reflections, and materials. Demonstrates advanced GPU rendering techniques with interactive camera controls and animated objects.
- Host: GitHub
- URL: https://github.com/wesfly/wgpu-raymarcher
- Owner: wesfly
- License: gpl-3.0
- Created: 2025-04-08T18:04:52.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-09T09:56:47.000Z (10 months ago)
- Last Synced: 2025-08-09T11:36:45.681Z (10 months ago)
- Topics: distance-fields, graphics, graphics-programming, raymarching, raymarching-distance-fields, raymarching-shader, rust, sdf, wgpu, wgpu-rs, wgpuengine
- Language: Rust
- Homepage: https://codeberg.org/wesfly/wgpu_raymarching
- Size: 404 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WGPU Raymarcher
A real-time interactive **raymarching renderer** built with [wgpu](https://github.com/gfx-rs/wgpu), written in **Rust** and **WGSL**. This project demonstrates distance field rendering techniques through raymarching.

## About Raymarching
Raymarching is a rendering technique that creates 3D scenes by "marching" along a ray until hitting a surface defined by mathematical distance functions. This approach enables complex visual effects that would be difficult to achieve with traditional polygon rendering.
## Features
- **Interactive Camera Control**: Rotate the camera by clicking and dragging the mouse
- **Distance Field Primitives**: Spheres, boxes, and planes with smooth blending
- **Dynamic Lighting & Shadows**: Soft shadows and diffuse lighting
- **Raymarched Reflections**: Reflections with variable quality
- **Material System**: Different materials with unique visual properties
- **Animated Objects**: Dynamic movement of scene elements
- **Customizable Performance**: Toggle FPS capping with the `F` key
- **User-Controlled Movement**: Control object position using W/S keys
## Technical Details
- Built with **wgpu** for cross-platform GPU access
- Shader code written in **WGSL** (WebGPU Shading Language)
- Leverages **Signed Distance Fields** (SDFs) for scene representation
- Implements smooth object blending with special material transitions
- Uses efficient ray marching with adaptive stepping
## Installation
1. Clone this repository:
```bash
git clone https://github.com/wesfly/wgpu-raymarcher.git
cd wgpu-raymarcher
```
2. Ensure you have Rust and Cargo installed, then run:
```bash
cargo run --release
```
## Controls
- **Mouse Drag**: Rotate camera
- **W/S Keys**: Move the green box forward/backward
- **F Key**: Toggle FPS cap
- **ESC**: Exit the application
## Acknowledgements
- [learn-wgpu](https://github.com/sotrh/learn-wgpu): For excellent WGPU learning resources
- [Inigo Quilez](https://iquilezles.org/): For pioneering work in signed distance fields
## License
This project is available under the GNU General Public License.
---
This repo is available on both [GitHub](https://github.com/wesfly/wgpu-raymarcher) and [Codeberg](https://codeberg.org/wesfly/wgpu_raymarching).