Skip to content
modkitv0.2

shadows.h

#include <modkit/shadows.h>10 functions · 6 structs · 2 enums · 9 typedefs · 2 macros

Transactional punctual-light shadow atlas preparation.

Functions

mk_shadows_atlas_texturefunction

mk_texture_t mk_shadows_atlas_texture(void)

Perform the shadows atlas texture operation.

Returns The resulting handle or value.

mk_shadows_commitfunction

bool mk_shadows_commit(void)

Publish only when all required passes succeeded; otherwise retain the last atlas.

Returns True when the operation succeeds.

mk_shadows_complete_passfunction

void mk_shadows_complete_pass(uint32_t index, bool success)

Report a required pass after its pass has ended.

ParameterTypeDescription
indexuint32_tZero-based index.
successboolValue for success.

mk_shadows_get_passfunction

bool mk_shadows_get_pass(uint32_t index, mk_shadow_pass_desc *out)

Get pass from the shadows.

ParameterTypeDescription
indexuint32_tZero-based index.
outmk_shadow_pass_desc *Value for out.

Returns True when the operation succeeds.

mk_shadows_get_statsfunction

void mk_shadows_get_stats(mk_shadow_stats *out)

Get stats from the shadows.

ParameterTypeDescription
outmk_shadow_stats *Value for out.

mk_shadows_pass_countfunction

uint32_t mk_shadows_pass_count(void)

Perform the shadows pass count operation.

Returns The resulting value.

mk_shadows_preparefunction

bool mk_shadows_prepare(const mk_shadow_prepare_desc *desc)

Build a pending generation from the immutable light snapshot of this frame.

ParameterTypeDescription
descconst mk_shadow_prepare_desc *Configuration descriptor.

Returns True when the operation succeeds.

mk_shadows_renderfunction

bool mk_shadows_render(const mk_shadow_prepare_desc *desc, mk_shadow_draw_callback draw, void *user_data)

Prepare, render, and transactionally publish all required shadow passes.

ParameterTypeDescription
descconst mk_shadow_prepare_desc *Configuration descriptor.
drawmk_shadow_draw_callbackValue for draw.
user_datavoid *Caller-provided context.

Returns True when the operation succeeds.

mk_shadows_system_initfunction

void mk_shadows_system_init(void)

Initialize the shadows system.

mk_shadows_system_shutdownfunction

void mk_shadows_system_shutdown(void)

Perform the shadows system shutdown operation.

Structs

mk_shadow_exceptionstruct

Data for shadow exception.

FieldTypeDescription
light_indexuint16_tThe light index.
requested_resolutionuint16_tThe requested resolution.
actual_resolutionuint16_tThe actual resolution.
face_countuint8_tThe face count.
reasonmk_shadow_exception_reasonThe reason.

mk_shadow_light_overridestruct

Data for shadow light override.

FieldTypeDescription
light_indexuint16_tThe light index.
resolutionuint16_tZero keeps the type default.
max_distancefloatRequired for infinite point/spot lights.
depth_biasfloatThe depth bias.
normal_biasfloatThe normal bias.
cascade_countuint8_tDirectional only; zero keeps the setting.

mk_shadow_pass_descstruct

Data for shadow pass desc.

FieldTypeDescription
passmk_pass_descThe pass.
viewfloatThe view.
projectionfloatThe projection.
light_indexuint16_tThe light index.
cascadeuint8_tThe cascade.
cube_faceuint8_tThe cube face.
shadow_slotuint16_tThe shadow slot.
atlas_scale_biasfloatscale.xy, bias.xy in sampled atlas UV.
max_distancefloatThe max distance.
depth_biasfloatThe depth bias.
normal_biasfloatThe normal bias.
point_face_seam_tolerancefloatThe point face seam tolerance.

mk_shadow_prepare_descstruct

Data for shadow prepare desc.

FieldTypeDescription
cameraconst mk_camera *The camera.
settingsmk_shadow_settingsThe settings.
overridesconst mk_shadow_light_override *The overrides.
override_countuint16_tThe override count.
caster_generationuint64_tThe caster generation.

mk_shadow_settingsstruct

Data for shadow settings.

FieldTypeDescription
atlas_sizeuint16_tZero selects 4096 desktop, 2048 web.
directional_tile_sizeuint16_tZero selects 1024.
spot_tile_sizeuint16_tZero selects 1024.
point_face_sizeuint16_tZero selects 512.
minimum_tile_sizeuint16_tZero selects 128.
directional_cascadesuint8_tZero selects four; valid range 1..4.
atlas_ring_sizeuint16_tDeprecated minimum; effective size is frame latency + 1.
directional_max_distancefloatZero selects min(camera far, 100).
cascade_split_lambdafloatZero selects 0.65.
cascade_blendfloatZero selects 0.10 of the cascade interval.
depth_biasfloatZero selects 0.0015 normalized depth at 1024px.
normal_biasfloatZero selects at least 0.01 world units.
point_face_seam_tolerancefloatZero selects a 0.02 dominant-axis blend band.

mk_shadow_statsstruct

Data for shadow stats.

FieldTypeDescription
pending_generationuint64_tThe pending generation.
published_generationuint64_tThe published generation.
atlas_bytesuint64_tAllocated atlas bytes; includes old and replacement rings during a resize.
required_passesuint32_tThe required passes.
completed_passesuint32_tThe completed passes.
downscaled_tilesuint32_tThe downscaled tiles.
dropped_lightsuint32_tThe dropped lights.
exceptionsmk_shadow_exceptionThe exceptions.
exception_countuint8_tThe exception count.
exceptions_truncatedboolThe exceptions truncated.
atlas_sizeuint16_tThe atlas size.
atlas_ring_sizeuint16_tThe atlas ring size.
depth_modemk_shadow_depth_modeThe depth mode.
activeboolThe active.
reusedboolThe reused.
pendingboolThe pending.

Enums

mk_shadow_depth_modeenum

Values for shadow depth mode.

ValueDescription
MK_SHADOW_DEPTH_NONESelects none.
MK_SHADOW_DEPTH_D16_COMPARESelects d16 compare.
MK_SHADOW_DEPTH_D16_MANUALSelects d16 manual.
MK_SHADOW_DEPTH_RGBA8_PACKEDSelects rgba8 packed.

mk_shadow_exception_reasonenum

Values for shadow exception reason.

ValueDescription
MK_SHADOW_EXCEPTION_DOWNSCALEDSelects downscaled.
MK_SHADOW_EXCEPTION_PASS_CAPACITYSelects pass capacity.
MK_SHADOW_EXCEPTION_ATLAS_CAPACITYSelects atlas capacity.
MK_SHADOW_EXCEPTION_MISSING_DISTANCESelects missing distance.

Typedefs

mk_shadow_depth_modetypedef

typedef enum mk_shadow_depth_mode mk_shadow_depth_mode

Values for shadow depth mode.

mk_shadow_draw_callbacktypedef

typedef bool(*) mk_shadow_draw_callback(const mk_shadow_pass_desc *pass, void *user_data)

Callback used for shadow draw callback.

mk_shadow_exceptiontypedef

typedef struct mk_shadow_exception mk_shadow_exception

Data for shadow exception.

mk_shadow_exception_reasontypedef

typedef enum mk_shadow_exception_reason mk_shadow_exception_reason

Values for shadow exception reason.

mk_shadow_light_overridetypedef

typedef struct mk_shadow_light_override mk_shadow_light_override

Data for shadow light override.

mk_shadow_pass_desctypedef

typedef struct mk_shadow_pass_desc mk_shadow_pass_desc

Data for shadow pass desc.

mk_shadow_prepare_desctypedef

typedef struct mk_shadow_prepare_desc mk_shadow_prepare_desc

Data for shadow prepare desc.

mk_shadow_settingstypedef

typedef struct mk_shadow_settings mk_shadow_settings

Data for shadow settings.

mk_shadow_statstypedef

typedef struct mk_shadow_stats mk_shadow_stats

Data for shadow stats.

Macros

MK_SHADOW_MAX_EXCEPTIONSdefine

MK_SHADOW_MAX_EXCEPTIONS

Maximum supported shadow exceptions.

MODKIT_MAX_SHADOW_PASSESdefine

MODKIT_MAX_SHADOW_PASSES

Maximum supported modkit shadow passes.