Transforms GLSL source code into optimized JavaScript, enabling WebGL shaders to run without a GPU or WebGL context. Current stable version is 3.0.3. Maintained as part of stackgl ecosystem. Key differentiators: converts vectors/matrices to typed arrays, expands swizzles, applies expression optimizations, and provides stdlib for environment compatibility. Supports both GLSL ES 100 and 300 versions. Can be used programmatically or as a stream via glsl-parser. Suitable for headless rendering, testing, and education.
npm install glsl-transpilerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Transpile a basic GLSL vertex shader to JavaScript using custom uniform/attribute mappers.
Use dynamic import or switch to ESM imports.
Prefer programmatic API unless streaming is required.
Wrap texture data in ndarray or provide width/height metadata.
Set optimize: false or enable debug: true to preserve original structure.
Replace require with dynamic import: const GLSL = await import('glsl-transpiler')Use import GLSL from 'glsl-transpiler' (default import) not import { GLSL } from 'glsl-transpiler'Use import compile from 'glsl-transpiler/stream.js' (with .js extension)