Repository navigation
naga-wasm: naga's shader translator as an npm package (WGSL, GLSL, SPIR-V, HLSL, MSL)
#10421
Closed
ryansuhartanto
started this conversation in
Show and tell
Replies: 1 comment 4 replies
|
So long as you're not claiming any ownership of "Naga" as a name, I think this is fine. We might want to choose a different name for your package, so there's no confusion, but OFC referencing Naga through things like @gfx-rs/wgpu, thoughts? |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi all, I've published naga-wasm, which compiles naga to WebAssembly so JavaScript projects can translate shaders in Node or the browser without shelling out to the naga CLI.
There's also a handle API (
parseWgsl->validate->writeGlsl/writeHlsl/...) so you can parse once and write several outputs, and errors come back as aNagaErrorcarrying naga's full formatted report with source spans.For example, you can make a small Vite plugin that turns a .wgsl file into WebGL-ready GLSL:
Then
import { vertex, fragment } from "./shader.wgsl?glsl"and hand them to a WebGL helper like TWGL.js.The major version tracks naga's (currently 30.x), and the bundled version is exported as
nagaVersion.Repo at https://github.com/kekkon-nexus/naga-wasm
Feedback welcome, especially on writer options you'd want exposed or anything that doesn't map well to JS. Thanks to the wgpu team for naga!
All reactions