Small World Engine API Reference - v0.76.20
    Preparing search index...

    Function lightClusterCoverage

    • Computes which cluster cells a single light's bounding sphere can possibly reach, by projecting the sphere's screen-space footprint (X/Y) and its radial-distance range (Z) -- the same approach cluster_cull.wgsl's lightCoverage() uses on WebGPU, kept here as a pure, backend-neutral function so the WebGL2 CPU culling pass can reuse and unit-test it directly. Falls back to covering the whole X/Y grid when the light center is behind the camera or the camera sits inside the sphere (a projected NDC center would be meaningless there) -- over-inclusion is safe, dropping a light that's actually visible is not.

      Parameters

      • viewDist: number

        Radial distance from the camera to the light center.

      • radius: number

        The light's range/radius.

      • ndcX: number

        Light center's screen-space NDC X (only meaningful when clipW > 0).

      • ndcY: number

        Light center's screen-space NDC Y (only meaningful when clipW > 0).

      • clipW: number

        The clip-space W component from projecting the light center through vp.

      • projScaleX: number

        Projection matrix diagonal term [0][0].

      • projScaleY: number

        Projection matrix diagonal term [1][1].

      • screenWidth: number

        Canvas width in pixels.

      • screenHeight: number

        Canvas height in pixels.

      • tileSize: [number, number]

        Screen-space tile size in pixels, [width, height].

      • dims: ClusterGridDims

        Grid dimensions from computeClusterCounts().

      • near: number

        Camera near-plane distance.

      • far: number

        Camera far-plane distance.

      Returns LightClusterCoverage