The pack
wgslGlsl
function wgslGlsl(): Pack<{ wgslGlsl: WgslGlslApi }>
The wgsl-glsl pack: the WGSL-to-GLSL snippet translator the WebGL2 fallback and the effect packs share.
Helpers
wgslSnippetToGLSL
function wgslSnippetToGLSL(code: string, scope: SnippetScope, helpers?: SnippetHelpers): string
Translate one WGSL snippet body to GLSL ES 3.0, against the names the
template declares. Throws an Error naming the unsupported construct — the
caller is expected to report it and skip the pass, never to splice a partial
result. helpers adds a template's own helper functions (a 3D template's
noise3, say) to the shared set.
Types
ScopeType
type ScopeType = string | { members: Record<string, string> }
The scope a snippet is translated against: name → GLSL type, or a struct.
SnippetHelpers
type SnippetHelpers = Record<string, { args: string[]; ret: string }>
Helper functions a template declares beyond the shared set, by name: each argument's GLSL type and the return type. A template that passes one must declare it, with that name and signature, in both dialects.
SnippetScope
type SnippetScope = Record<string, ScopeType>
The full set of names a snippet can reference, each with its GLSL type.
WgslGlslApi
interface WgslGlslApi
game.wgslGlsl: the snippet translator.
wgslSnippetToGLSL: typeof wgslSnippetToGLSL— Translate a WGSL snippet body to GLSL ES 3.0 against the names its template declares. Throws, naming the construct, on anything outside the snippet contract.


