Detecting WebGPU… WGSL enable magma_ray_query; MIT License

Hardware Ray Tracing
for the Open Web.

Write inline WebGPU ray queries once. Run with zero overhead on native DXR 1.1 in Magma / MegaBrowser, and automatically fall back to a 2-level 8-bin SAH BVH compute shader in Chrome, Edge, Firefox & Safari.

Launch Crytek Sponza →
$ npm i @vibegameengine/magma-ray-query-shim
View on GitHub
WebGPU Adapter: probing…
Fullscreen ↗
262,267
Real Crytek Sponza triangles traced live in WebGPU
0 ms
JS wrapper overhead on native Magma DXR 1.1
8-bin SAH
2-level BLAS/TLAS BVH fallback for standard browsers
1 Shader
Identical WGSL & WebGPU API across hardware & software
Interactive Showcase

Four real-time ray tracing scenes.

Every demo runs live in your browser using the exact same enable magma_ray_query; WGSL shader on both hardware DXR 1.1 and software BVH.

Crytek Sponza WebGPU Path Tracing Flagship · 262k tris

Crytek Sponza — Path Tracing & SVGF

Authentic Khronos Crytek Sponza glTF with 25 PBR textures, multi-bounce Global Illumination, soft sunlight, temporal accumulation, and demodulated À-Trous denoising.

262k glTFGI + SVGFWASD Fly
Launch →
Ray-Traced Cornell Box Scene 2 · Soft Shadows

Ray-Traced Cornell Box

Multi-bounce mirror and glossy reflections, jittered area-light soft shadows, smooth barycentric normals, and live material presets.

Soft ShadowsGlossy Refl
Launch →
Dynamic Multi-Instance RT Arena Scene 3 · Dynamic TLAS

Dynamic Multi-Instance RT Arena

Up to 20 animated BLAS/TLAS instances rebuilt every frame with instance_custom_data procedural materials, Fresnel reflections, and orbiting light shadows.

Dynamic TLAS20 Instances
Launch →
Glass Dielectrics and Ray-Traced AO Scene 4 · Dielectrics & AO

Glass Dielectrics & Ray-Traced AO

Smooth normals via barycentrics, Snell refraction & TIR via front_face, object_to_world transforms, stratified hemisphere AO, and debug views.

barycentricsfront_faceRT AO
Launch →
Architecture

Zero-overhead DXR 1.1. Automatic BVH fallback.

One SDK call inspects adapter.features.has("ray-query") and selects the optimal backend transparently.

Dual-Backend Execution

EnvironmentModePath
Magma / MegaBrowser "hardware" Direct native DXR 1.1 pass-through
Chrome / Edge / Firefox / Safari "software-bvh" 2-level 8-bin SAH BVH + WGSL transpile

2024–2026 Neural Denoiser Research

Survey of the newest neural & real-time path tracing denoisers on GitHub — including Neural Ray Reconstruction, online neural cross-regression, neural kernel-predicting transformers, Cooperative Vectors / Slang, and WebGPU compute denoisers.

Developer Experience

Drop in. Trace rays in 10 lines.

init.tsTypeScript / WebGPU
import { installMagmaRayQueryShim, RAY_QUERY_FEATURE_NAME } from "@vibegameengine/magma-ray-query-shim";

const adapter = await navigator.gpu.requestAdapter();
const hasDXR  = adapter.features.has(RAY_QUERY_FEATURE_NAME);
const device  = await adapter.requestDevice(
  hasDXR ? { requiredFeatures: [RAY_QUERY_FEATURE_NAME] } : {}
);

const { mode } = installMagmaRayQueryShim(device);
console.log("RT backend:", mode); // "hardware" | "software-bvh"
pathtracer.wgslWGSL Inline Ray Query
enable magma_ray_query;

@group(0) @binding(0) var scene: acceleration_structure;

fn traceRay(origin: vec3<f32>, dir: vec3<f32>) -> RayIntersection {
  var rq: ray_query;
  let desc = RayDesc(1u, 0xFFu, 0.002, 150.0, origin, dir);
  rayQueryInitialize(&rq, scene, desc);
  while (rayQueryProceed(&rq)) {}
  return rayQueryGetCommittedIntersection(&rq);
}