Skip to content
gavinyorkPublic

About

TypeScript 3D rendering engine for the browser - one codebase targeting WebGL, WebGL2 and WebGPU, with a visual editor and node-graph materials

Topics

Resources

Contributing

Stars

143 stars

Watchers

3 watching

Forks

Repository files navigation

Bringing advanced real-time rendering techniques to the browser.

A WebGPU-first TypeScript engine with skin, hair, water and terrain rendering,
a single-source shader system, and a visual editor.

Documentation  |  Demos  |  Online Editor  |  API Reference

CI npm License: MIT


Star this repo   Sponsor Ko-fi


FFT ocean with buoyancy FFT ocean
wave simulation + buoyancy
Clipmap terrain with grass Clipmap terrain
runtime texturing + grass
PBR car rendering Car
PBR + IBL + reflections
Clustered lighting with many lights Clustered lighting
hundreds of dynamic lights
Order-independent transparency Transparency
order-independent blending
VRM character rendering Characters
VRM, skinning, blend shapes

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.

Natural environments Ocean water driven by FFT, Gerstner or FBM waves, with caustics, refraction and interaction with floating objects. Clipmap terrain with runtime texturing, virtual texturing and grass layers. Atmospheric sky and height fog.

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, and rect area lights. TAA, SSGI, SSR, SSAO, bloom, motion blur, tonemapping and color grading.

Also in the box

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, water or terrain 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 on bounce light indoors — there is no baked or probe-based global illumination yet, only screen-space GI. Probe-based GI is planned after 1.0;
  • you need long-term API stability guarantees today (see Status).

Support

Zephyr3D is developed and maintained by one person in their free time — the engine, the editor, the documentation and the demos are all unpaid work. 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.

Sponsor on GitHub   Support on Ko-fi

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 gavinyork2024@outlook.com 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 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, maintained by one person. The engine is well past prototype — it drives its own editor and a set of demos — but it has not reached 1.0 and APIs still change between minor versions. Pin your versions.

Every change runs through unit tests and a visual regression suite that renders reference scenes on both WebGPU and WebGL2 in CI. The 1.0 release will mark a stable core API with a documented deprecation policy; until then, long-term API stability is not something this project can promise.

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.

About

TypeScript 3D rendering engine for the browser - one codebase targeting WebGL, WebGL2 and WebGPU, with a visual editor and node-graph materials

Topics

Resources

Contributing

Stars

143 stars

Watchers

3 watching

Forks

Sponsor this project

Used by

Contributors

Languages