Skip to content
modkitv0.2

post.h

#include <modkit/post.h>5 functions · 3 structs · 3 typedefs

Post-processing package (opt-in).

An OPT-IN package (MODKIT_ENABLE_POST, default OFF). Explicit post FX applied as fullscreen passes over a linear HDR scene target. Bloom stays linear HDR; tone mapping produces linear LDR; grading, vignette, and FXAA remain linear LDR; and mk_post_present performs the sole display conversion. Typical use (explicit / app-wired) render the scene into a linear HDR target, then tone map and present it:

Functions

mk_post_bloomfunction

mk_texture_t mk_post_bloom(mk_texture_t hdr_src, const mk_bloom_params *params)

Generate a bloom texture from a linear HDR source (dual-filter pyramid: soft-knee prefilter -> downsample chain -> additive tent upsample).

The returned texture is owned by the package (a half-resolution, auto-resizing internal target reused across frames) do NOT destroy it. Sample it via the tone-map composite: pass it as mk_post_tonemap_params.bloom. Lazily self-initializes. Returns MK_TEXTURE_INVALID on failure / invalid source.

ParameterTypeDescription
hdr_srcmk_texture_tLinear HDR scene texture (e.g. an RGBA16F scene target's color).
paramsconst mk_bloom_params *Bloom threshold/knee/levels (NULL = sensible defaults).

Returns Bloom texture to feed into mk_post_tonemap_linear, or MK_TEXTURE_INVALID.

mk_post_fxaa_linearfunction

mk_result mk_post_fxaa_linear(mk_texture_t ldr_src, mk_render_target_t dst)

Anti-alias a linear LDR image with FXAA into another linear target.

ParameterTypeDescription
ldr_srcmk_texture_tLinear post-tonemap texture to anti-alias.
dstmk_render_target_tLinear destination render target.

Returns MK_SUCCESS or a validation/initialization error.

mk_post_grade_linearfunction

mk_result mk_post_grade_linear(mk_texture_t ldr_src, mk_render_target_t dst, const mk_post_grade_params *params)

Apply an optional 3D LUT and vignette to linear LDR.

This stage remains linear and belongs between tone mapping and FXAA/present. An invalid LUT uses an identity transform, allowing vignette-only use.

ParameterTypeDescription
ldr_srcmk_texture_tValue for ldr src.
dstmk_render_target_tValue for dst.
paramsconst mk_post_grade_params *Value for params.

Returns MK_SUCCESS or an error result.

mk_post_presentfunction

mk_result mk_post_present(mk_texture_t linear_src, mk_render_target_t dst, mk_color_space_t output_color_space)

Present a linear LDR texture with exactly one requested output conversion.

AUTO derives offscreen output from target metadata and requests sRGB for the backbuffer. An sRGB destination uses hardware conversion from a linear shader write. A linear destination requested as sRGB uses shader encoding. Requesting linear output for an sRGB destination is invalid.

ParameterTypeDescription
linear_srcmk_texture_tLinear LDR texture.
dstmk_render_target_tDestination target; MK_RENDER_TARGET_INVALID selects the backbuffer.
output_color_spacemk_color_space_tAUTO, LINEAR, or SRGB.

Returns MK_SUCCESS or a validation/initialization error.

mk_post_tonemap_linearfunction

mk_result mk_post_tonemap_linear(mk_texture_t hdr_src, mk_render_target_t dst, const mk_post_tonemap_params *params)

Composite optional bloom and tone map an HDR source into linear LDR.

dst must be a linear render target. Display encoding is deliberately excluded; pass the resulting texture to mk_post_fxaa_linear or mk_post_present. NULL params uses Reinhard at exposure 1.0 with no bloom.

ParameterTypeDescription
hdr_srcmk_texture_tLinear HDR texture (e.g. an RGBA16F scene target's color attachment).
dstmk_render_target_tLinear destination render target.
paramsconst mk_post_tonemap_params *Tonemap operator, exposure, and optional bloom.

Returns MK_SUCCESS or a validation/initialization error.

Structs

mk_bloom_paramsstruct

Bloom configuration (dual-filter pyramid).

FieldTypeDescription
thresholdfloatSoft-knee luminance threshold (default ~1.0).
kneefloatSoft-knee width around the threshold (default ~0.5).
mipsintPyramid level count (<=0 => default 6; clamped to resolution).

mk_post_grade_paramsstruct

Linear-LDR color grading and vignette configuration.

FieldTypeDescription
lutmk_texture_tOptional cubic 3D LUT authored for linear LDR.
vignettefloatRadial vignette strength 0..1.

mk_post_tonemap_paramsstruct

Tonemap pass configuration.

FieldTypeDescription
opintOperator: mk_tonemap_op.
exposurefloatLinear exposure multiplier applied before tonemap (<=0 => 1.0).
bloommk_texture_tOptional bloom texture (mk_post_bloom result); MK_TEXTURE_INVALID = none.
bloom_intensityfloatLinear weight for the bloom add (e.g.

Typedefs

mk_bloom_paramstypedef

typedef struct mk_bloom_params mk_bloom_params

Bloom configuration (dual-filter pyramid).

mk_post_grade_paramstypedef

typedef struct mk_post_grade_params mk_post_grade_params

Linear-LDR color grading and vignette configuration.

mk_post_tonemap_paramstypedef

typedef struct mk_post_tonemap_params mk_post_tonemap_params

Tonemap pass configuration.