@pixi/3d
    Preparing search index...

    Interface ShaderBitTemplateAdvanced

    The source a shader compiles from: its entry points, with {{slot}} markers the bits fill

    {{header}} takes every bit's header code and the generated declarations for the attributes, varyings and bindings. Every other marker takes the bits' code for that slot, in bit order, and a marker no bit fills is removed.

    The WGSL template holds both entry points, so its slots carry the stage as a prefix: a bit's vertex.body fills {{vertexBody}}. Each GLSL template holds one stage, so vertex.body fills the vertex template's {{body}}. To write the bits' outputs, a template adds the slots ShaderBit#outputs lists; any other template writes its fragment outputs itself.

    Shaders are cached by template identity, so build a template once and don't change it.

    const pbrTemplate: ShaderBitTemplate = {
    bindGroups: [{ name: "global", ubo: true }, "camera", "batch"],
    gpu: `
    {{header}}
    @vertex fn mainVertex(input: VertexInput) -> VertexOutput {
    var output: VertexOutput;
    {{vertexBody}}
    return output;
    }
    @fragment fn mainFragment(input: FragmentInput) -> @location(0) vec4<f32> {
    {{fragmentBody}}
    }
    `,
    gl: {
    vertex: `#version 300 es
    {{header}}
    void main() {
    {{body}}
    }
    `,
    fragment: `#version 300 es
    {{header}}
    void main() {
    {{body}}
    }
    `,
    },
    };
    interface ShaderBitTemplate {
        bindGroups: readonly TemplateBindGroup[];
        gl?: { fragment: string; vertex: string };
        gpu?: string;
    }
    Index
    bindGroups: readonly TemplateBindGroup[]

    The bind groups the shader binds, in @group index order

    A template that draws meshes lists global then camera, since the engine binds those by index, and a material's template adds batch after them for the material's data. List global as { name: 'global', ubo: true } wherever it appears, or the compile throws.

    gl?: { fragment: string; vertex: string }

    The GLSL sources for WebGL, one per stage, each with a #version 300 es line

    Type Declaration

    • Readonlyfragment: string

      GLSL fragment shader template

    • Readonlyvertex: string

      GLSL vertex shader template

    gpu?: string

    The WGSL source for WebGPU, holding both entry points, named mainVertex and mainFragment