For documentation, see: Getting Started with JavaScript/TypeScript
For sample code, start with one of the wesl-js Examples.
WESL is an extended version of WebGPU's WGSL shading language. Everything you know from WGSL just works.
WESL adds features:
- imports to split shaders into modular, reusable files
- conditional compiliation to configure shader variations at compile time or run time
- shader libraries on npm and cargo, for community sharing of shader code modules
This wesl library contains a TypeScript WESL linker. wesl can be used at runtime or at build time to assemble WESL and WGSL modules for WebGPUk
import package::colors::chartreuse; // 1. modularize shaders in separate files import random_wgsl::pcg_2u_3f; // 2. use shader libraries from npm/cargo fn random_color(uv: vec2u) -> vec3f { var color = pcg_2u_3f(uv); @if(DEBUG) color = chartreuse; // 3. set conditions at runtime or build time return color; }