Skip to content

Type Alias: ShaderDomain ​

ts
type ShaderDomain = "sprite" | "post" | "surface";

Shaders and materials — backend-neutral asset model.

A .shader file is GLSL ES 3.00 that defines ONE entry function for its domain; backends wrap it in their own boilerplate (inputs, uniforms, output), so shader files never mention a renderer. The file opens with a header block comment holding JSON:

/*

Shader ​

*/ vec4 sprite(vec4 color, vec2 uv)

Domains and their entry points: sprite — vec4 sprite(vec4 color, vec2 uv): one 2D drawable's pixels. color is the drawable's colour at uv (straight alpha), uv is 0..1 over the drawable, y-up. sampleSprite(uv) reads it elsewhere (outside 0..1 = transparent). post — vec4 post(vec4 color, vec2 uv): a camera's image; uv is 0..1 over its viewport, y-up; sampleScreen(uv) reads it elsewhere. surface — reserved for lit 3D meshes. Every domain also gets uTime (seconds), uSize (drawable / viewport size in px) and sampleTexture(sampler2D, uv) for texture uniforms (y-up uv, straight alpha). Uniforms are declared in the header — the backend declares them, the code just uses them by name.

A .material file is JSON: a shader id plus values for its uniforms (texture uniforms take a texture asset id). Drawing components reference a material and may override values per object.

© 2026 PlayAdGentic