Header menu logo Mibo.Raylib

Culling (visibility helpers)

Mibo.Elmish.Culling is a helper module that keeps visibility math separate from your renderer and your spatial partitioning.

It operates on geometric primitives such as:

3D: frustum culling

Create a Frustum from the camera's View * Projection matrix and test geometry:

// Extract frustum from camera matrices
let frustum = Frustum(Matrix4x4.Multiply(cam.View, cam.Projection))

if Culling.isVisible frustum entitySphere then
    // submit draw commands
    ()

Or for axis-aligned bounding boxes:

if Culling.isGenericVisible frustum nodeBounds then
    ()

2D: rectangle overlap

Use Camera2D.viewportBounds with Culling.isVisible2D:

let viewBounds = Camera2D.viewportBounds camera viewportWidth viewportHeight

if Culling.isVisible2D viewBounds spriteBounds then
    ()

What this is not

This module doesn't try to be your spatial index.

See also: Camera and Rendering overview.

val frustum: obj
val viewBounds: obj

Type something to start searching.