Phaser AE

WGSL to GLSL snippets

Free packv3.0.0-12D and 3DRenderers

The translator between the two backends' shader languages. Effects written once in WGSL for WebGPU still draw on the WebGL2 fallback, and anything that cannot be translated says so instead of drawing black.

This is a Free pack. Every phaser.io account can use it in their games.

Released October 19, 2026 · updated October 20, 2026

WGSL to GLSL snippets: a screenshot of its demo
A note about these graphics

Expansion packs don't come with graphics. This screenshot is one way of drawing what the pack does, made for its demo: none of the sprites, tiles or backgrounds in it are in the pack.

That's by design. A pack is a game's logic, mechanics and effects, and it works with whatever art you give it. Some packs draw effects, backdrops or 3D scenes of their own, but none carries a game's sprites.

So the look is yours. Make the art on phaser.io, bring your own, or let your agent draw it in code: the same pack can look like anything.

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.