2 releases
| 0.1.1 | Dec 31, 2025 |
|---|---|
| 0.1.0 | Dec 31, 2025 |
#342 in Science
Used in 4 crates
(via xdl-stdlib)
95KB
2K
SLoC
XDL-VIZ3D: 3D Volume Visualization
High-fidelity 3D visualization engine for scientific simulations using WebGPU.
Features
- Volume Ray Marching: GPU-accelerated volume rendering
- Interactive Navigation: Arcball camera with mouse/keyboard controls
- Scientific Colormaps: Viridis, Plasma, Rainbow, Turbo, and more
- Isosurface Extraction: Render iso-contours of 3D scalar fields
- Cross-Platform: Runs on Metal, Vulkan, DirectX 12, and WebGPU
- Web Export: Compile to WebAssembly for browser visualization
Quick Start
From XDL Scripts
; rayleigh_taylor.xdl - Create and visualize 3D volume data
; Create 3D volume
size = 64
density = FLTARR(size, size, size)
; Fill with data
FOR i=0, size-1 DO FOR j=0, size-1 DO FOR k=0, size-1 DO $
density[i,j,k] = EXP(-((i-32)^2 + (j-32)^2 + (k-32)^2) / 400.0)
; Initialize and render
VIZ3D_INIT, WINDOW_SIZE=[1280, 720]
VIZ3D_COLORMAP, 'VIRIDIS'
VIZ3D_VOLUME, density, DIMENSIONS=[size, size, size]
VIZ3D_RENDER, /INTERACTIVE
Run Demo
# From XDL project root
xdl examples/demo/volume_render_simple.xdl
# Or the full Rayleigh-Taylor simulation
xdl examples/demo/rayleigh_taylor.xdl
Architecture
XDL Script (.xdl)
↓
xdl-stdlib (VIZ3D_* functions)
↓
xdl-viz3d (Rust rendering engine)
↓
wgpu (WebGPU abstraction)
↓
GPU (Metal/Vulkan/DX12/WebGPU)
API Functions
Core Functions
VIZ3D_INIT- Initialize visualization systemVIZ3D_VOLUME- Upload volume data to GPUVIZ3D_RENDER- Render current volumeVIZ3D_COLORMAP- Set colormapVIZ3D_CAMERA- Configure cameraVIZ3D_TRANSFER- Set transfer functionVIZ3D_ISOSURFACE- Extract and render isosurface
See docs/VIZ3D_IMPLEMENTATION.md for full API documentation.
Examples
Simple Volume
examples/demo/volume_render_simple.xdl - Basic Gaussian blob
Rayleigh-Taylor Instability
examples/demo/rayleigh_taylor.xdl - Full fluid dynamics simulation
Building
# Build the crate
cargo build --release -p xdl-viz3d
# Run tests
cargo test -p xdl-viz3d
# Build for WebAssembly
cargo build --target wasm32-unknown-unknown --release -p xdl-viz3d
Implementation Status
- Project structure and Cargo setup
- Demo XDL scripts created
- Implementation plan documented
- Core rendering engine
- Camera system
- Volume ray marching shaders
- Colormap system
- stdlib integration
- WebAssembly export
See TODO list for remaining work.
Performance
Expected performance on modern GPUs:
| Grid Size | Frame Rate | Memory |
|---|---|---|
| 64³ | 60+ FPS | ~10 MB |
| 128³ | 60 FPS | ~50 MB |
| 256³ | 30 FPS | ~200 MB |
| 512³ | 15 FPS | ~1 GB |
Dependencies
wgpu- GPU abstraction layerwinit- Cross-platform windowingglam- Linear algebrabytemuck- Safe GPU data casting
Contributing
See main XDL project Contributing section.
License
GPL-2.0 (same as XDL project)
Dependencies
~23–65MB
~1M SLoC