Atlaslog
Atlaslog / luma.gl / API reference / ShaderModule
luma.gl · API reference

ShaderModule

Quick answer

ShaderModule is a plain object type in v9, not a constructible class. It bundles name, optional vs and fs fragments, uniformTypes and inject hooks, which shadertools concatenates when assembling shader sources. Pass modules to Model or Shader to reuse lighting, picking and projection code.

Last verified 2026-11-03 · luma.gl 9.4 · Cite this page
type ShaderModule = { name, vs?, fs?, uniformTypes?, inject? }
Key points
Example
const waveModule = {
  name: 'wave',
  fs: `
float wave(float x, float freq) {
  return sin(x * freq) * 0.5 + 0.5;
}
`,
  inject: {
    'fs:#main-end': 'fragColor.rgb *= wave(vUV.x, 6.0);'
  }
};
const model = new Model(device, {
  vs: vsSource,
  fs: fsSource,
  modules: [waveModule],
  attributes: { positions: positions },
  bufferLayout: [
    { name: 'positions', stepMode: 'vertex', format: 'float32x3' }
  ],
  vertexCount: 3,
  topology: 'triangle-list'
});
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). ShaderModule. https://www.jingweizhi.com/en/lumagl/api/shader-module.html (accessed 2026-11-03).