gavinyork/zephyr3d
Acerca de
TypeScript 3D rendering engine for the browser - one codebase targeting WebGL, WebGL2 and WebGPU, with a visual editor and node-graph materials
Diseño y multimediaCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
Original
Bringing advanced real-time rendering techniques to the browser.
Characters and open worlds, rendered in the browser with WebGPU.
A TypeScript engine with a visual editor, falling back to WebGL2.
Documentation | Demos | Online Editor | API Reference
Click any image to run it live. · All demos →
Quick start
npm install --save @zephyr3d/base @zephyr3d/scene @zephyr3d/backend-webgpu @zephyr3d/backend-webgl
A lit sphere you can orbit around. It runs on WebGPU when the browser supports it and falls back to WebGL2 otherwise:
import { Vector3, Vector4 } from '@zephyr3d/base';
import {
Scene, Application, LambertMaterial, Mesh,
OrbitCameraController, PerspectiveCamera, SphereShape,
DirectionalLight, getInput, getEngine
} from '@zephyr3d/scene';
import { backendWebGPU } from '@zephyr3d/backend-webgpu';
import { backendWebGL2 } from '@zephyr3d/backend-webgl';
const myApp = new Application({
backend: (await backendWebGPU.supported()) ? backendWebGPU : backendWebGL2,
canvas: document.querySelector('#my-canvas')
});
myApp.ready().then(function () {
const scene = new Scene();
const light = new DirectionalLight(scene);
light.lookAt(Vector3.one(), Vector3.zero(), Vector3.axisPY());
const material = new LambertMaterial();
material.albedoColor = new Vector4(1, 0, 0, 1);
new Mesh(scene, new SphereShape(), material);
scene.mainCamera = new PerspectiveCamera(scene, Math.PI / 3, 1, 100);
scene.mainCamera.lookAt(new Vector3(0, 0, 4), Vector3.zero(), Vector3.axisPY());
scene.mainCamera.controller = new OrbitCameraController();
getInput().use(scene.mainCamera.handleEvent, scene.mainCamera);
getEngine().setRenderable(scene, 0);
myApp.run();
});
Basic Framework walks through the HTML scaffold and what each step does. Which packages you actually need depends on your case; Installation has the breakdown.
Rendering techniques
Most of the engine's depth goes into a few areas that are usually hard to get on the web.
Characters Skin with subsurface scattering and transmission, an eye material with socket occlusion, and hair with Kajiya-Kay and Marschner shading, expanded into strands on the GPU and simulated in compute shaders. MToon and VRM support for stylized characters.
Open worlds Clipmap terrain with virtual texturing, spline roads that cut and fill the terrain, procedural grass, and foliage that turns into octahedral impostors in the distance. Ocean water driven by FFT, Gerstner or FBM waves, with breaking shore waves, foam, caustics, refraction and floating objects. An atmospheric sky with volumetric clouds and cloud shadows, dynamic global illumination from DDGI probes, and vehicles and rigid bodies on Rapier physics. These systems work together: a road clears the grass along it, cloud shadows reach the sky and the bounce light, and the GI reads the terrain's colour.
Shadows and transparency PCF (several variants), PCSS, ESM, VSM, SSM and DOM shadows, with cascaded shadow maps and contact shadows — pick per light based on the quality/cost tradeoff you want. Three order-independent transparency backends: A-buffer (WebGPU), dual depth peeling, and weighted blended.
Lighting and post-processing PBR materials (metallic-roughness and specular-glossiness) with image-based lighting and physical lighting units, clustered lighting for hundreds of dynamic lights, rect area lights, and probe-based global illumination (WebGPU). TAA, SSGI, SSR, SSAO, bloom, motion blur, tonemapping and color grading.
Also in the box
- Pipeline — Forward+ renderer organized as a render graph with automatic resource pooling and history buffers. Hi-Z, depth prepass, GPU picking, instancing with GPU culling, mesh LOD, render bundles, multi-view rendering.
- Materials — Lambert/Blinn/Unlit, a mixin-based system for custom materials, and material blueprints authored as node graphs in the editor.
- Animation and simulation — skeletal and keyframe animation with blending, masks and an action controller; inverse kinematics (CCD, FABRIK, two-bone), joint dynamics, spring chains, GPU cloth, morph targets and geometry caches.
- Assets — glTF/GLB, FBX, Alembic and hair curve importers, KTX2 texture compression, a prefab system, a virtual file system, and reference-counted resources.
The documentation covers these topic by topic — when to use each one, how to tune it, and its backend limitations — rather than just listing properties.
One shader source, two backends
Rather than maintaining parallel GLSL and WGSL sources, you describe the shader once in TypeScript:
const program = device.buildRenderProgram({
vertex(pb) {
this.$inputs.pos = pb.vec3().attrib('position');
this.$inputs.uv = pb.vec2().attrib('texCoord0');
this.$outputs.uv = pb.vec2();
this.xform = pb.defineStruct([pb.mat4('mvpMatrix')])().uniform(0);
pb.main(function () {
this.$builtins.position =
pb.mul(this.xform.mvpMatrix, pb.vec4(this.$inputs.pos, 1));
this.$outputs.uv = this.$inputs.uv;
});
},
fragment(pb) {
this.$outputs.color = pb.vec4();
this.tex = pb.tex2D().uniform(0);
pb.main(function () {
this.$outputs.color = pb.textureSample(this.tex, this.$inputs.uv);
});
}
});
From this single source the engine emits WGSL and WebGL2 GLSL (std140 UBOs, explicit outputs), together with the matching WebGPU bind group layouts and computed buffer layouts. Bindings and shader code stay in sync, and you avoid hand-written variants that drift apart.
The Writing Shaders guide shows the generated output side by side for each backend.
A visual editor built on the engine
The editor is itself built on the Scene and Device APIs, so what you see in it is what the engine renders. It covers scene editing, the content browser, node-graph material blueprints, terrain sculpting and texturing, animation editing, TypeScript scripting bound to scene entities, and a plugin API for custom tools and panels.
The desktop build (Electron) adds local project folders with persistent storage, an embedded MCP server that lets AI agents and external tools drive the editor, and a built-in LLM assistant. API keys are stored locally, encrypted at rest.
Editor documentation: overview · quick start · desktop editor
Is it a good fit?
Zephyr3D is a good fit if you are
- building a web project that needs character or open-world rendering beyond what general-purpose libraries offer out of the box;
- building custom tools or an in-house editor, and want an engine whose source you can follow end to end;
- doing web rendering research, or learning how a complete engine is put together.
It may not be the right choice yet if
- you depend on a large third-party ecosystem of plugins, loaders and community examples;
- your scenes rely heavily on bounce light indoors — DDGI probe-based global illumination is available on WebGPU but is still maturing; screen-space GI supplements it on both backends;
- you need a game framework — Zephyr3D provides rendering, scenes, physics and an editor, but no gameplay framework or networking;
- most of your users are on WebGL2 only — global illumination, volumetric clouds, GPU grass and virtual texturing need WebGPU;
- you need long-term API stability guarantees today (see Status).
Support
Zephyr3D is independent and has no company behind it. If any of it has been useful to you, sponsorship is what pays for hosting, CI and testing hardware, and buys focused blocks of time for new features, performance work and documentation.
Ways to help that cost nothing, but matter just as much:
- Star the repo — it is the main signal that keeps the project visible.
- Ask and answer in Discussions — real usage questions shape the docs and the roadmap.
- Report what breaks, with a minimal reproduction if you can. For a rendering engine, a screenshot plus the backend and GPU you are on is worth a lot.
- Tell people when a demo or a write-up helped — that reach is how a project like this finds the people who end up sponsoring it.
For commercial use, integration help or a support arrangement, open a thread in
Discussions or write to
[email protected] so we can talk about what you need.
Packages
The engine is split so you install only what you use. Packages are versioned independently.
| Package | Role |
|---|---|
@zephyr3d/base |
Math, virtual file system, events, reference counting |
@zephyr3d/device |
Graphics abstraction, shader generator, resource binding |
@zephyr3d/backend-webgl |
WebGL2 backend |
@zephyr3d/backend-webgpu |
WebGPU backend |
@zephyr3d/scene |
Scene graph, materials, lighting, shadows, animation, post FX |
@zephyr3d/loaders |
glTF/GLB, FBX, Alembic, hair curve importers |
@zephyr3d/imgui |
ImGui bindings for debug panels and tool UI |
@zephyr3d/modelgen |
Dependency-free procedural mesh generation |
@zephyr3d/procgen |
Procedural scene generation (shape grammar, wave function collapse) |
@zephyr3d/editor |
Visual editor, desktop shell, plugin API types |
Backend differences
The engine targets two graphics APIs and falls back silently when a capability is missing, so test on your actual targets rather than assuming that error-free code means a feature is active.
- WebGPU — the full feature set, including compute shaders. Required for global illumination, volumetric clouds, GPU grass, terrain virtual texturing, water caustics, A-buffer OIT, DOM shadows, GPU cloth and hair simulation, and terrain shading cache.
- WebGL2 — broad coverage, no compute shaders. WebGL1 is no longer supported.
Zephyr3D also defaults to a reverse-Z depth convention for better far-distance precision,
selected once at load time via the __ZEPHYR3D_REVERSE_Z__ build-time define. If you write custom
materials, use the depth constants exported from @zephyr3d/base (DEPTH_CLEAR_VALUE,
DEPTH_COMPARE_DEFAULT, ...) rather than hard-coding 0 or 1. Full details, including per-backend
behavior and the current limitation around oblique-clipped projections, are in
apps/doc/web/en/reverse-z.md.
Documentation
| Overview | What the engine is and where to start |
| Installation | Which packages you need for your case |
| Scene API guide | Materials, lighting, shadows, animation, post FX, terrain, water |
| Device API guide | Writing your own renderer on the graphics abstraction |
| Editor guide | Visual workflow, scripting, plugins, publishing |
| API reference | Generated from source |
| Demos | Ocean, terrain, car, clustered lighting, OIT, IK and more |
Documentation is available in English and 简体中文.
Status
Actively developed. The engine drives its own editor and a set of demos. Before 1.0, minor versions may still change the API; 1.0 will mark a stable core API with semver guarantees and a documented deprecation policy.
Every change runs through unit tests and a visual regression suite that renders reference scenes on both WebGPU and WebGL2 in CI.
Questions and design discussions are best raised in Discussions; bugs and confirmed feature requests belong in the issue tracker. If you want to send a pull request, read CONTRIBUTING.md first — it explains where the project is and is not ready to take outside code.
License
Released under the MIT License.
Explorar proyectos relacionados
Cargando…
