API

Interface MaterialPlugin

Plain-data material plugin. All behaviour is via optional function members.

interface MaterialPlugin {
    defines?: Record<string, number | boolean>;
    dynamic?: boolean;
    isEnabled?: boolean;
    name: string;
    priority?: number;
    bindTextures?(out: PluginTextureBinding[]): void;
    getActiveTextures?(out: Texture2D[]): void;
    getCustomCode?(
        shaderType: "vertex" | "fragment",
    ): Partial<Record<MaterialPluginPoint, string>> | null;
    getSamplers?(): PluginSamplerDecl[];
    getUniforms?(): { ubo?: PluginUboField[] };
    getVaryings?(): PluginVaryingDecl[];
    writeUbo?(data: Float32Array, offsets: ReadonlyMap<string, number>): void;
}
Index
defines?: Record<string, number | boolean>

Static defines folded into the pipeline cache key (and available to the plugin when it builds its custom code).

dynamic?: boolean

Re-upload this plugin's Standard-material UBO values before every rendered frame. PBR plugin values already follow the material UBO's versioned update path.

isEnabled?: boolean

Default true when attached. A disabled plugin contributes no shader code but still changes the pipeline cache key (so toggling forces a rebuild).

name: string

Stable identifier. Factored into the pipeline cache key.

priority?: number

Lower runs first. Default 500.