Transforms GLSL shader source code into optimized JavaScript. Version 1.8.6 is stable, though the package has seen infrequent updates since 2018. It converts vectors and matrices to arrays, expands swizzles, applies expression optimizations, and provides a stdlib for environment compatibility. Part of the stackgl ecosystem, it is a key tool for running WebGL shaders on the CPU or in headless environments. Differs from alternatives like glsl.js by offering more granular control over uniform/attribute replacement and stream-based processing.
npm install glsl-transpiler2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Compiles a simple GLSL vertex shader to JavaScript with custom uniform/attribute mappings.
Remove usage of `blend` option. Use custom uniform/attribute replacements instead.
Migrate imports to ES modules: `import GLSL from 'glsl-transpiler'`.
Use function with two parameters if you need node: `uniform(name, node)`.
Change option name to `sourceMap`.
Ensure version string is exactly '100 es' or '300 es'.
Provide version option: `GLSL({ version: '100 es' })`.Call the default export: `const compile = GLSL(options); compile(source)`.
Provide uniform and attribute options: `GLSL({ uniform: name => 'uniforms.' + name })`.No dependency data recorded yet.