magic-pixels
    Preparing search index...

    Type Alias Material

    A material is plain data: shader sources per shading language, a draw mode and a uniforms object. A renderer picks the language it understands (glsl for WebGL2; a WebGPU renderer would read wgsl), compiles one program per material (shared by all meshes using it) and uploads the uniforms on every draw, skipping the ones that did not change. Replacing a shader source recompiles the program on the next render.

    type Material = {
        depthTest?: boolean;
        depthWrite?: boolean;
        drawMode: DrawMode;
        glsl?: ShaderSource;
        side?: Side;
        transparent?: boolean;
        uniforms: Uniforms;
    }
    Index
    depthTest?: boolean

    Discard fragments behind what is already drawn. Default true.

    depthWrite?: boolean

    Write fragment depth into the depth buffer. Defaults to true, except when transparent is true and depthWrite is not set explicitly.

    drawMode: DrawMode
    side?: Side

    Which faces are drawn. Default 'double': no culling, as today.

    transparent?: boolean

    Alpha blending (SRC_ALPHA, ONE_MINUS_SRC_ALPHA) instead of overwriting the framebuffer, and depth writes off unless depthWrite says otherwise. Also determines draw order: transparent meshes are drawn after opaque ones, back to front. Default false.

    uniforms: Uniforms