Skip to content
modkitv0.2

clustered_lighting.h

#include <modkit/clustered_lighting.h>3 functions · 3 structs · 1 enums · 3 typedefs

Forward+ light-list texture construction.

Functions

mk_clustered_clearfunction

void mk_clustered_clear(void)

Clear the clustered.

mk_clustered_get_layoutfunction

void mk_clustered_get_layout(mk_clustered_layout *out)

Copy the currently prepared clustered-lighting layout.

ParameterTypeDescription
outmk_clustered_layout *Receives the layout.

mk_clustered_preparefunction

bool mk_clustered_prepare(const mk_clustered_prepare_desc *desc)

Build or update cached clustered textures for the current light generation.

Local lights use conservative point-sphere or spot-cone bounding spheres. The CPU upload completes before this call returns, so no compute-to-sample barrier is required. Core PBR consumes stages 8-10; extension-heavy PBR remains bounded forward because those stages belong to extension maps. A failed build retains the previous allocation but disables its generation and selects bounded forward mode.

ParameterTypeDescription
descconst mk_clustered_prepare_desc *Configuration descriptor.

Returns True when the operation succeeds.

Structs

mk_clustered_layoutstruct

Prepared cluster dimensions, counters, and GPU textures.

FieldTypeDescription
light_generationuint64_tImmutable frame-light generation consumed.
cluster_xuint16_tThe cluster x.
cluster_yuint16_tThe cluster y.
cluster_zuint16_tThe cluster z.
light_texture_widthuint16_tEight texels, one row per source light.
light_texture_heightuint16_tThe light texture height.
grid_texture_widthuint16_tcluster_x.
grid_texture_heightuint16_tcluster_y * cluster_z.
index_texture_widthuint16_t1024 texels.
index_texture_heightuint16_tThe index texture height.
local_light_countuint32_tThe local light count.
directional_light_countuint32_tThe directional light count.
index_countuint32_tThe index count.
overflow_clustersuint32_tThe overflow clusters.
dropped_indicesuint32_tThe dropped indices.
light_texturemk_texture_tShared RGBA32F light and shadow data.
grid_texturemk_texture_tRGBA32F; RG is float offset/count.
index_texturemk_texture_tR32F; exact float indices, capped at 2^24.

mk_clustered_prepare_descstruct

Inputs used to prepare clustered-lighting textures for a frame.

FieldTypeDescription
cameraconst mk_camera *The camera.
viewport_widthuint16_tThe viewport width.
viewport_heightuint16_tThe viewport height.
settingsmk_clustered_settingsThe settings.

mk_clustered_settingsstruct

Cluster-grid dimensions and storage limits.

FieldTypeDescription
tile_widthuint16_tZero selects 64 pixels.
tile_heightuint16_tZero selects 64 pixels.
depth_slicesuint8_tZero selects 24.
max_lights_per_clusteruint16_tZero selects 64.
max_indicesuint32_tZero selects 1,048,576.

Enums

@272374001373325103324230062076152076105103021111enum

Fixed texture stages reserved by clustered lighting.

ValueDescription
MK_LIGHTING_SHADOW_STAGESelects shadow stage.
MK_LIGHTING_CLUSTER_LIGHT_STAGESelects cluster light stage.
MK_LIGHTING_CLUSTER_GRID_STAGESelects cluster grid stage.
MK_LIGHTING_CLUSTER_INDEX_STAGESelects cluster index stage.

Typedefs

mk_clustered_layouttypedef

typedef struct mk_clustered_layout mk_clustered_layout

Prepared cluster dimensions, counters, and GPU textures.

mk_clustered_prepare_desctypedef

typedef struct mk_clustered_prepare_desc mk_clustered_prepare_desc

Inputs used to prepare clustered-lighting textures for a frame.

mk_clustered_settingstypedef

typedef struct mk_clustered_settings mk_clustered_settings

Cluster-grid dimensions and storage limits.