Skip to content
modkitv0.2

pbr.h

#include <modkit/pbr.h>21 functions · 7 structs · 6 enums · 13 typedefs · 18 macros

glTF 2.0 metallic-roughness materials and ratified KHR extensions.

Factors are stored as floats and passed to the shader without quantization or conversion to another material model. Use MK_PBR_DESC_INIT or mk_pbr_desc_default() before overriding fields. A zero-initialized descriptor is literal zero; only mk_pbr_material(NULL) implies the glTF defaults.

Functions

mk_pbr_active_extension_maskfunction

uint32_t mk_pbr_active_extension_mask(const mk_pbr_desc *desc)

Compute the exact compile-time extension-code mask for a descriptor.

ParameterTypeDescription
descconst mk_pbr_desc *Configuration descriptor.

Returns The resulting value.

mk_pbr_coveragefunction

float mk_pbr_coverage(mk_pbr_blend blend, float evaluated_alpha, float alpha_cutoff, bool *discarded)

Return coverage for the glTF alpha mode.

ParameterTypeDescription
blendmk_pbr_blendValue for blend.
evaluated_alphafloatValue for evaluated alpha.
alpha_cutofffloatValue for alpha cutoff.
discardedbool *Value for discarded.

Returns The resulting value.

mk_pbr_debug_channel_namefunction

const char * mk_pbr_debug_channel_name(mk_pbr_debug_channel channel)

Perform the PBR debug channel name operation.

ParameterTypeDescription
channelmk_pbr_debug_channelValue for channel.

Returns A borrowed pointer, or NULL when unavailable.

mk_pbr_desc_defaultfunction

mk_pbr_desc mk_pbr_desc_default(void)

Perform the PBR desc default operation.

Returns The resulting value.

mk_pbr_desc_validatefunction

mk_result mk_pbr_desc_validate(const mk_pbr_desc *desc)

Validate dependencies and the supported UV-set range without touching GPU state.

ParameterTypeDescription
descconst mk_pbr_desc *Configuration descriptor.

Returns MK_SUCCESS or an error result.

mk_pbr_last_resultfunction

mk_result mk_pbr_last_result(void)

Last PBR creation/validation result on the calling thread.

Returns MK_SUCCESS or an error result.

mk_pbr_materialfunction

mk_material_t mk_pbr_material(const mk_pbr_desc *desc)

Perform the PBR material operation.

ParameterTypeDescription
descconst mk_pbr_desc *Configuration descriptor.

Returns The resulting handle or value.

mk_pbr_material_record_packfunction

mk_result mk_pbr_material_record_pack(const mk_pbr_desc *desc, mk_pbr_material_record *out)

Serialize a descriptor into the documented 14-texel deferred record.

ParameterTypeDescription
descconst mk_pbr_desc *Configuration descriptor.
outmk_pbr_material_record *Value for out.

Returns MK_SUCCESS or an error result.

mk_pbr_material_table_layout_makefunction

mk_result mk_pbr_material_table_layout_make(uint32_t max_texture_size, mk_pbr_material_table_layout *out)

Compute the material-table shape for a device maxTextureSize.

ParameterTypeDescription
max_texture_sizeuint32_tMax texture size in bytes.
outmk_pbr_material_table_layout *Value for out.

Returns MK_SUCCESS or an error result.

mk_pbr_material_texel_addressfunction

mk_result mk_pbr_material_texel_address(const mk_pbr_material_table_layout *layout, uint32_t material_row, uint32_t field, uint32_t *x, uint32_t *y)

Translate one material row/field into a nearest-fetch material-table texel.

ParameterTypeDescription
layoutconst mk_pbr_material_table_layout *Value for layout.
material_rowuint32_tValue for material row.
fielduint32_tValue for field.
xuint32_t *Value for x.
yuint32_t *Value for y.

Returns MK_SUCCESS or an error result.

mk_pbr_sampler_budget_validatefunction

mk_result mk_pbr_sampler_budget_validate(const mk_pbr_sampler_budget *budget, uint32_t *required_samplers)

Count every renderer-owned sampler consumed by an evaluation/resolve pass.

ParameterTypeDescription
budgetconst mk_pbr_sampler_budget *Value for budget.
required_samplersuint32_t *Value for required samplers.

Returns MK_SUCCESS or an error result.

mk_pbr_surface_entry_packfunction

mk_result mk_pbr_surface_entry_pack(const mk_pbr_surface_entry *entry, float out_rgba[4])

Serialize/deserialize the exact-float 256x256 surface table entry.

ParameterTypeDescription
entryconst mk_pbr_surface_entry *Value for entry.
out_rgbafloatReceives the RGBA.

Returns MK_SUCCESS or an error result.

mk_pbr_surface_entry_unpackfunction

mk_result mk_pbr_surface_entry_unpack(const float rgba[4], mk_pbr_surface_entry *out)

Perform the PBR surface entry unpack operation.

ParameterTypeDescription
rgbaconst floatValue for RGBA.
outmk_pbr_surface_entry *Value for out.

Returns MK_SUCCESS or an error result.

mk_pbr_surface_id_decodefunction

mk_result mk_pbr_surface_id_decode(const float rgba[4], uint32_t *surface_id)

Decode PBR surface ID.

ParameterTypeDescription
rgbaconst floatValue for RGBA.
surface_iduint32_t *Value for surface ID.

Returns MK_SUCCESS or an error result.

mk_pbr_surface_id_encodefunction

mk_result mk_pbr_surface_id_encode(uint32_t surface_id, float out_rgba[4])

Byte-normalized ownership encoding used by the core attachment.

ParameterTypeDescription
surface_iduint32_tValue for surface ID.
out_rgbafloatReceives the RGBA.

Returns MK_SUCCESS or an error result.

mk_pbr_surface_id_range_validatefunction

mk_result mk_pbr_surface_id_range_validate(uint32_t base_surface_id, uint32_t instance_count, bool stencil_available)

Validate a contiguous surface-ID allocation for the stencil capability.

ParameterTypeDescription
base_surface_iduint32_tValue for base surface ID.
instance_countuint32_tNumber of instance entries.
stencil_availableboolValue for stencil available.

Returns MK_SUCCESS or an error result.

mk_pbr_surface_texel_addressfunction

void mk_pbr_surface_texel_address(uint32_t surface_id, uint32_t *x, uint32_t *y)

Perform the PBR surface texel address operation.

ParameterTypeDescription
surface_iduint32_tValue for surface ID.
xuint32_t *Value for x.
yuint32_t *Value for y.

mk_pbr_transmission_capturefunction

void mk_pbr_transmission_capture(mk_texture_t opaque_color)

Perform the PBR transmission capture operation.

ParameterTypeDescription
opaque_colormk_texture_tValue for opaque color.

mk_pbr_variant_atfunction

bool mk_pbr_variant_at(uint32_t index, mk_pbr_variant_info *out_info)

Perform the PBR variant at operation.

ParameterTypeDescription
indexuint32_tZero-based index.
out_infomk_pbr_variant_info *Receives the info.

Returns True when the operation succeeds.

mk_pbr_variant_countfunction

uint32_t mk_pbr_variant_count(void)

Inspect the manifest-generated variant registry.

Returns The resulting value.

mk_pbr_variant_findfunction

bool mk_pbr_variant_find(uint32_t extension_mask, mk_pbr_variant_family family, mk_pbr_variant_info *out_info)

Find PBR variant.

ParameterTypeDescription
extension_maskuint32_tValue for extension mask.
familymk_pbr_variant_familyValue for family.
out_infomk_pbr_variant_info *Receives the info.

Returns True when the operation succeeds.

Structs

mk_pbr_descstruct

Data for PBR desc.

FieldTypeDescription
nameconst char *The name.
base_color_factorfloatThe base color factor.
metallic_factorfloatThe metallic factor.
roughness_factorfloatThe roughness factor.
emissive_factorfloatThe emissive factor.
emissive_strengthfloatThe emissive strength.
iorfloatThe ior.
specular_factorfloatThe specular factor.
specular_color_factorfloatThe specular color factor.
clearcoat_factorfloatThe clearcoat factor.
clearcoat_roughness_factorfloatThe clearcoat roughness factor.
clearcoat_normal_scalefloatThe clearcoat normal scale.
sheen_color_factorfloatThe sheen color factor.
sheen_roughness_factorfloatThe sheen roughness factor.
iridescence_factorfloatThe iridescence factor.
iridescence_iorfloatThe iridescence ior.
iridescence_thickness_minfloatThe iridescence thickness min.
iridescence_thickness_maxfloatThe iridescence thickness max.
transmission_factorfloatThe transmission factor.
diffuse_transmission_factorfloatThe diffuse transmission factor.
diffuse_transmission_color_factorfloatThe diffuse transmission color factor.
thickness_factorfloatThe thickness factor.
attenuation_distancefloatThe attenuation distance.
attenuation_colorfloatThe attenuation color.
dispersionfloatThe dispersion.
anisotropy_strengthfloatThe anisotropy strength.
anisotropy_rotationfloatThe anisotropy rotation.
legacy_diffuse_factorfloatThe legacy diffuse factor.
legacy_specular_factorfloatThe legacy specular factor.
legacy_glossiness_factorfloatThe legacy glossiness factor.
workflowmk_pbr_workflowThe workflow.
volume_enabledboolThe volume enabled.
normal_scalefloatThe normal scale.
occlusion_strengthfloatThe occlusion strength.
blendmk_pbr_blendThe blend.
alpha_cutofffloatThe alpha cutoff.
double_sidedboolThe double sided.
unlitboolThe unlit.
base_color_texturemk_pbr_texture_viewThe base color texture.
metallic_roughness_texturemk_pbr_texture_viewThe metallic roughness texture.
normal_texturemk_pbr_texture_viewThe normal texture.
occlusion_texturemk_pbr_texture_viewThe occlusion texture.
emissive_texturemk_pbr_texture_viewThe emissive texture.
clearcoat_texturemk_pbr_texture_viewThe clearcoat texture.
clearcoat_roughness_texturemk_pbr_texture_viewThe clearcoat roughness texture.
clearcoat_normal_texturemk_pbr_texture_viewThe clearcoat normal texture.
sheen_color_texturemk_pbr_texture_viewThe sheen color texture.
sheen_roughness_texturemk_pbr_texture_viewThe sheen roughness texture.
specular_texturemk_pbr_texture_viewThe specular texture.
specular_color_texturemk_pbr_texture_viewThe specular color texture.
iridescence_texturemk_pbr_texture_viewThe iridescence texture.
iridescence_thickness_texturemk_pbr_texture_viewThe iridescence thickness texture.
transmission_texturemk_pbr_texture_viewThe transmission texture.
diffuse_transmission_texturemk_pbr_texture_viewThe diffuse transmission texture.
diffuse_transmission_color_texturemk_pbr_texture_viewThe diffuse transmission color texture.
thickness_texturemk_pbr_texture_viewThe thickness texture.
anisotropy_texturemk_pbr_texture_viewThe anisotropy texture.
legacy_diffuse_texturemk_pbr_texture_viewThe legacy diffuse texture.
legacy_specular_glossiness_texturemk_pbr_texture_viewThe legacy specular glossiness texture.

mk_pbr_material_recordstruct

One material record ready for an RGBA32F texture upload.

FieldTypeDescription
texelsfloatThe texels.

mk_pbr_material_table_layoutstruct

Data for PBR material table layout.

FieldTypeDescription
max_texture_sizeuint32_tThe max texture size.
columnsuint32_tThe columns.
capacityuint32_tThe capacity.

mk_pbr_sampler_budgetstruct

Data for PBR sampler budget.

FieldTypeDescription
material_sourcesuint32_tThe material sources.
material_tablesuint32_tThe material tables.
core_targetsuint32_tThe core targets.
renderer_resourcesuint32_tThe renderer resources.
lighting_targetsuint32_tThe lighting targets.
light_resourcesuint32_tThe light resources.
ibl_resourcesuint32_tThe ibl resources.
extension_targetsuint32_tThe extension targets.
transmission_resourcesuint32_tThe transmission resources.
max_samplersuint32_tThe max samplers.

mk_pbr_surface_entrystruct

Data for PBR surface entry.

FieldTypeDescription
material_rowuint32_tThe material row.
resolve_flagsuint32_tThe resolve flags.
evaluated_attachment_validityuint32_tThe evaluated attachment validity.

mk_pbr_texture_viewstruct

One glTF textureInfo/normalTextureInfo/occlusionTextureInfo binding.

FieldTypeDescription
texturemk_texture_tThe texture.
texcoorduint8_tThe texcoord.
offsetfloatThe offset.
rotationfloatThe rotation.
scalefloatThe scale.
sampler_flagsuint32_tThe sampler flags.
has_sampler_overrideboolThe has sampler override.

mk_pbr_variant_infostruct

Data for PBR variant info.

FieldTypeDescription
iduint32_tThe ID.
extension_maskuint32_tThe extension mask.
familymk_pbr_variant_familyThe family.
sampler_stage_maskuint16_tThe sampler stage mask.
nameconst char *The name.

Enums

mk_pbr_blendenum

Values for PBR blend.

ValueDescription
MK_PBR_BLEND_OPAQUESelects opaque.
MK_PBR_BLEND_MASKSelects mask.
MK_PBR_BLEND_BLENDSelects blend.

mk_pbr_debug_channelenum

Values for PBR debug channel.

ValueDescription
MK_PBR_DEBUG_OFFSelects off.
MK_PBR_DEBUG_TEXCOORD0Selects texcoord0.
MK_PBR_DEBUG_TEXCOORD1Selects texcoord1.
MK_PBR_DEBUG_NORMAL_TEXTURESelects normal texture.
MK_PBR_DEBUG_GEOMETRY_NORMALSelects geometry normal.
MK_PBR_DEBUG_GEOMETRY_TANGENTSelects geometry tangent.
MK_PBR_DEBUG_GEOMETRY_BITANGENTSelects geometry bitangent.
MK_PBR_DEBUG_GEOMETRY_TANGENT_WSelects geometry tangent w.
MK_PBR_DEBUG_SHADING_NORMALSelects shading normal.
MK_PBR_DEBUG_ALPHASelects alpha.
MK_PBR_DEBUG_AOSelects ao.
MK_PBR_DEBUG_EMISSIVESelects emissive.
MK_PBR_DEBUG_BASECOLORSelects basecolor.
MK_PBR_DEBUG_METALLICSelects metallic.
MK_PBR_DEBUG_ROUGHNESSSelects roughness.
MK_PBR_DEBUG_CLEARCOAT_STRENGTHSelects clearcoat strength.
MK_PBR_DEBUG_CLEARCOAT_ROUGHNESSSelects clearcoat roughness.
MK_PBR_DEBUG_CLEARCOAT_NORMALSelects clearcoat normal.
MK_PBR_DEBUG_SHEEN_COLORSelects sheen color.
MK_PBR_DEBUG_SHEEN_ROUGHNESSSelects sheen roughness.
MK_PBR_DEBUG_SPECULAR_STRENGTHSelects specular strength.
MK_PBR_DEBUG_SPECULAR_COLORSelects specular color.
MK_PBR_DEBUG_TRANSMISSIONSelects transmission.
MK_PBR_DEBUG_THICKNESSSelects thickness.
MK_PBR_DEBUG_DIFFUSE_TRANSMISSIONSelects diffuse transmission.
MK_PBR_DEBUG_DIFFUSE_TRANSMISSION_COLORSelects diffuse transmission color.
MK_PBR_DEBUG_IRIDESCENCESelects iridescence.
MK_PBR_DEBUG_IRIDESCENCE_THICKNESSSelects iridescence thickness.
MK_PBR_DEBUG_ANISOTROPYSelects anisotropy.
MK_PBR_DEBUG_ANISOTROPY_DIRECTIONSelects anisotropy direction.
MK_PBR_DEBUG_MULTISCATTER_COLORSelects multiscatter color.
MK_PBR_DEBUG_SINGLESCATTER_COLORSelects singlescatter color.
MK_PBR_DEBUG_PRESCATTER_PASSSelects prescatter pass.
MK_PBR_DEBUG_DIFFUSE_IBLSelects diffuse ibl.
MK_PBR_DEBUG_SPECULAR_IBLSelects specular ibl.
MK_PBR_DEBUG_F0Selects f0.
MK_PBR_DEBUG_ENV_REFLECTIONSelects env reflection.
MK_PBR_DEBUG_IRRADIANCESelects irradiance.
MK_PBR_DEBUG_INDIRECTSelects indirect.
MK_PBR_DEBUG_REFLECT_DIRSelects reflect dir.
MK_PBR_DEBUG_ALBEDO_TEXSelects albedo tex.
MK_PBR_DEBUG_SHEEN_ENERGYSelects sheen energy.
MK_PBR_DEBUG_SHEEN_IBLSelects sheen ibl.
MK_PBR_DEBUG_SHEEN_DIRECTSelects sheen direct.
MK_PBR_DEBUG_COUNTSelects count.

mk_pbr_material_texelenum

Values for PBR material texel.

ValueDescription
MK_PBR_TEXEL_BASE_COLORSelects base color.
MK_PBR_TEXEL_METALLIC_ROUGHNESS_NORMAL_AOSelects metallic roughness normal ao.
MK_PBR_TEXEL_EMISSIVESelects emissive.
MK_PBR_TEXEL_ALPHA_FLAGSSelects alpha flags.
MK_PBR_TEXEL_IOR_SPECULARSelects ior specular.
MK_PBR_TEXEL_CLEARCOATSelects clearcoat.
MK_PBR_TEXEL_SHEENSelects sheen.
MK_PBR_TEXEL_IRIDESCENCESelects iridescence.
MK_PBR_TEXEL_ANISOTROPY_TRANSMISSIONSelects anisotropy transmission.
MK_PBR_TEXEL_VOLUMESelects volume.
MK_PBR_TEXEL_DISPERSION_DIFFUSE_TRANSMISSIONSelects dispersion diffuse transmission.
MK_PBR_TEXEL_DIFFUSE_TRANSMISSION_LEGACY_DIFFUSESelects diffuse transmission legacy diffuse.
MK_PBR_TEXEL_LEGACY_SPECULARSelects legacy specular.
MK_PBR_TEXEL_WORKFLOWSelects workflow.
MK_PBR_TEXEL_COUNTSelects count.

mk_pbr_texture_downgradeenum

Values for PBR texture downgrade.

ValueDescription
MK_PBR_DOWNGRADE_CHARLIE_SHEEN_CUBESelects charlie sheen cube.
MK_PBR_DOWNGRADE_ANISOTROPY_TEXTURESelects anisotropy texture.
MK_PBR_DOWNGRADE_IRIDESCENCE_TEXTURESelects iridescence texture.
MK_PBR_DOWNGRADE_SPECULAR_TEXTURESelects specular texture.
MK_PBR_DOWNGRADE_CLEARCOAT_NORMALSelects clearcoat normal.
MK_PBR_DOWNGRADE_SHEEN_TEXTURESelects sheen texture.
MK_PBR_DOWNGRADE_PACKED_CLEARCOAT_TEXTURESelects packed clearcoat texture.
MK_PBR_DOWNGRADE_DIFFUSE_TRANSMISSION_TEXTURESelects diffuse transmission texture.
MK_PBR_DOWNGRADE_THICKNESS_TEXTURESelects thickness texture.
MK_PBR_DOWNGRADE_TRANSMISSION_TEXTURESelects transmission texture.

mk_pbr_variant_familyenum

Values for PBR variant family.

ValueDescription
MK_PBR_FAMILY_NONESelects none.
MK_PBR_FAMILY_CORESelects core.
MK_PBR_FAMILY_SURFACESelects surface.
MK_PBR_FAMILY_TRANSMISSIONSelects transmission.
MK_PBR_FAMILY_FULL_MATERIALSelects full material.

mk_pbr_workflowenum

The two glTF material workflows accepted by the importer.

ValueDescription
MK_PBR_WORKFLOW_METALLIC_ROUGHNESSSelects metallic roughness.
MK_PBR_WORKFLOW_SPECULAR_GLOSSINESSSelects specular glossiness.

Typedefs

mk_pbr_blendtypedef

typedef enum mk_pbr_blend mk_pbr_blend

Values for PBR blend.

mk_pbr_debug_channeltypedef

typedef enum mk_pbr_debug_channel mk_pbr_debug_channel

Values for PBR debug channel.

mk_pbr_desctypedef

typedef struct mk_pbr_desc mk_pbr_desc

Data for PBR desc.

mk_pbr_material_recordtypedef

typedef struct mk_pbr_material_record mk_pbr_material_record

One material record ready for an RGBA32F texture upload.

mk_pbr_material_table_layouttypedef

typedef struct mk_pbr_material_table_layout mk_pbr_material_table_layout

Data for PBR material table layout.

mk_pbr_material_texeltypedef

typedef enum mk_pbr_material_texel mk_pbr_material_texel

Values for PBR material texel.

mk_pbr_sampler_budgettypedef

typedef struct mk_pbr_sampler_budget mk_pbr_sampler_budget

Data for PBR sampler budget.

mk_pbr_surface_entrytypedef

typedef struct mk_pbr_surface_entry mk_pbr_surface_entry

Data for PBR surface entry.

mk_pbr_texture_downgradetypedef

typedef enum mk_pbr_texture_downgrade mk_pbr_texture_downgrade

Values for PBR texture downgrade.

mk_pbr_texture_viewtypedef

typedef struct mk_pbr_texture_view mk_pbr_texture_view

One glTF textureInfo/normalTextureInfo/occlusionTextureInfo binding.

mk_pbr_variant_familytypedef

typedef enum mk_pbr_variant_family mk_pbr_variant_family

Values for PBR variant family.

mk_pbr_variant_infotypedef

typedef struct mk_pbr_variant_info mk_pbr_variant_info

Data for PBR variant info.

mk_pbr_workflowtypedef

typedef enum mk_pbr_workflow mk_pbr_workflow

The two glTF material workflows accepted by the importer.

Macros

MK_PBR_DESC_INITdefine

MK_PBR_DESC_INIT

Constant for PBR desc init.

MK_PBR_FEATURE_ANISOTROPYdefine

MK_PBR_FEATURE_ANISOTROPY

Constant for PBR feature anisotropy.

MK_PBR_FEATURE_CLEARCOATdefine

MK_PBR_FEATURE_CLEARCOAT

Constant for PBR feature clearcoat.

MK_PBR_FEATURE_DIFFUSE_TRANSMISSIONdefine

MK_PBR_FEATURE_DIFFUSE_TRANSMISSION

Constant for PBR feature diffuse transmission.

MK_PBR_FEATURE_DISPERSIONdefine

MK_PBR_FEATURE_DISPERSION

Constant for PBR feature dispersion.

MK_PBR_FEATURE_IRIDESCENCEdefine

MK_PBR_FEATURE_IRIDESCENCE

Constant for PBR feature iridescence.

MK_PBR_FEATURE_LEGACY_SPEC_GLOSSdefine

MK_PBR_FEATURE_LEGACY_SPEC_GLOSS

Constant for PBR feature legacy spec gloss.

MK_PBR_FEATURE_SHEENdefine

MK_PBR_FEATURE_SHEEN

Constant for PBR feature sheen.

MK_PBR_FEATURE_SPECULARdefine

MK_PBR_FEATURE_SPECULAR

Constant for PBR feature specular.

MK_PBR_FEATURE_TRANSMISSIONdefine

MK_PBR_FEATURE_TRANSMISSION

Constant for PBR feature transmission.

MK_PBR_FEATURE_UNLITdefine

MK_PBR_FEATURE_UNLIT

Constant for PBR feature unlit.

MK_PBR_FEATURE_VOLUMEdefine

MK_PBR_FEATURE_VOLUME

Constant for PBR feature volume.

MK_PBR_MATERIAL_TEXELSdefine

MK_PBR_MATERIAL_TEXELS

Constant for PBR material texels.

MK_PBR_MAX_SURFACESdefine

MK_PBR_MAX_SURFACES

Maximum supported PBR surfaces.

MK_PBR_SURFACE_RESOLVE_UNLITdefine

MK_PBR_SURFACE_RESOLVE_UNLIT

Constant for PBR surface resolve unlit.

MK_PBR_SURFACE_TABLE_HEIGHTdefine

MK_PBR_SURFACE_TABLE_HEIGHT

Constant for PBR surface table height.

MK_PBR_SURFACE_TABLE_WIDTHdefine

MK_PBR_SURFACE_TABLE_WIDTH

Constant for PBR surface table width.

MK_PBR_TEXTURE_VIEW_INITdefine

MK_PBR_TEXTURE_VIEW_INIT

Constant for PBR texture view init.