Packages and backends
For a rendering application, install @luma.gl/core and @luma.gl/engine. Core creates the device and its GPU resources. Engine’s Model combines geometry and shaders and draws them into a render pass. Both backend adapters ship with Core.
Choose packages for your task
| I want to… | Start here |
|---|---|
| Create buffers and textures or encode a custom pass | Core |
| Draw geometry, load glTF, or apply fullscreen effects | Engine |
| Reuse shader functions or customize how a model shades its fragments | Shaders |
| Compose GPU computations and pass results between operations | Graph |
| Explore retained scenes, compile Slang shaders, or integrate Three.js | ANARI, Slang, or Three.js |
For example, to animate a colored mesh, upload its vertices to a Core buffer and pass that buffer to an Engine model. Add a shader module if several models share the same coloring function. Add Graph if a computation produces new vertex positions each frame. See how the layers fit together for a worked example and the package reference for individual imports.
Choose a backend
For portable drawing, register both adapters. With best-available, luma.gl prefers supported WebGPU and otherwise selects WebGL 2. Handle device creation errors explicitly if your application needs to retry on another backend.
import {luma} from '@luma.gl/core/api';
import {webgpuAdapter} from '@luma.gl/core/webgpu';
import {webgl2Adapter} from '@luma.gl/core/webgl';
const device = await luma.createDevice({
type: 'best-available',
adapters: [webgpuAdapter, webgl2Adapter],
createCanvasContext: true
});
- Portable rendering: supply WGSL for WebGPU and GLSL ES 3.00 for WebGL 2. Check device features and limits before enabling optional effects.
- Compute pipelines or storage buffers: request
type: 'webgpu'. A compatible renderer alone does not guarantee support for a particular computation. - Existing GLSL-only rendering: request
type: 'webgl'or add WGSL before enabling both backends.
See Bundling for adapter imports and code splitting. See the Core backend comparison for detailed differences. The capabilities overview links to two detailed comparisons: the rendering and visualization matrix and the GPU data and compute matrix.
Further reading
WebGPU Fundamentals and WebGL 2 Fundamentals teach the underlying APIs. The WebGPU samples show individual techniques. See Learning Resources for specifications and glTF resources.