playcanvas-opti-pixel - v1.3.1
    Preparing search index...

    Class WebglCoverageBuffer

    WebGL2 coverage depth buffer.

    Reads the HZB mip nearest to maxWidth × maxHeight and packs its screen footprint with transform feedback to float view-space Z. Pixel i covers screen UV [i / width, (i + 1) / width] and reads the HZB texels under that slice. GPU→CPU download is a ring of readbackSlots PBO/fence reads (CoverageTFReadback). The next pack starts when a slot is free.

    Implements

    Index
    • Parameters

      • device: WebglGraphicsDevice

        WebGL2 device

      • maxWidth: number = 256

        CPU width, default 256

      • maxHeight: number = 128

        CPU height, default 128

      • minReadbackLag: number = 2

        minimum frameUpdate ticks before copying the download, default 2

      Returns WebglCoverageBuffer

    • Select a mip of an already-built pyramid, pack it into the CPU map, and start an async readback. The selected level is written to sourceMip. Device Z is linearized in the pack. No-op when this buffer or the pyramid is disabled, when cpuReadback is off, or without a pyramid texture. Also no-op when no readback slot is free, when a readback was already submitted this frame, or on a WebGL tick that readbackPeriod skips. Call after hzb.update / hzb.updateSceneDepth, once opaque depth is in the pyramid.

      Parameters

      Returns void

    • Set the packed-map cap. Omitted sizes keep the current cap.

      The readback ring holds maxWidth * maxHeight pixels and is rebuilt only when that count changes. A same-count change keeps in-flight captures and the published map. A rebuild drops them: cpuReady becomes false, cpuVersion increments, and cpuDepth is filled with 1e10.

      Screen size belongs to the HZB. A window resize does not call this, so in-flight captures and the published map stay.

      Parameters

      • maxWidth: number = ...
      • maxHeight: number = ...

      Returns void