LDKMaterialType
typedef enum LDKMaterialType{
LDK_MATERIAL_TYPE_INVALID=0,
LDK_MATERIAL_TYPE_TEXTURED_UNLIT=1,
LDK_MATERIAL_TYPE_TEXTURED=2,
LDK_MATERIAL_TYPE_VERTEX_COLOR_UNLIT=3,
LDK_MATERIAL_TYPE_VERTEX_COLOR=4
}LDKMaterialType;
Material descriptors, shader configuration, texture slots, and rendering properties.
typedef enum LDKMaterialType{
LDK_MATERIAL_TYPE_INVALID=0,
LDK_MATERIAL_TYPE_TEXTURED_UNLIT=1,
LDK_MATERIAL_TYPE_TEXTURED=2,
LDK_MATERIAL_TYPE_VERTEX_COLOR_UNLIT=3,
LDK_MATERIAL_TYPE_VERTEX_COLOR=4
}LDKMaterialType;
typedef enum LDKMaterialAlphaMode{
LDK_MATERIAL_ALPHA_MODE_OPAQUE=0,
LDK_MATERIAL_ALPHA_MODE_CUTOUT=1,
LDK_MATERIAL_ALPHA_MODE_BLEND=2
}LDKMaterialAlphaMode;
typedef enum LDKMaterialTextureFilter{
LDK_MATERIAL_TEXTURE_FILTER_NEAREST=0,
LDK_MATERIAL_TEXTURE_FILTER_LINEAR=1
}LDKMaterialTextureFilter;
typedef enum LDKMaterialTextureWrap{
LDK_MATERIAL_TEXTURE_WRAP_REPEAT=0,
LDK_MATERIAL_TEXTURE_WRAP_CLAMP=1,
LDK_MATERIAL_TEXTURE_WRAP_MIRROR=2
}LDKMaterialTextureWrap;
typedef enum LDKMaterialTextureMipFilter{
LDK_MATERIAL_TEXTURE_MIP_FILTER_NONE=0,
LDK_MATERIAL_TEXTURE_MIP_FILTER_NEAREST=1,
LDK_MATERIAL_TEXTURE_MIP_FILTER_LINEAR=2
}LDKMaterialTextureMipFilter;
#define LDK_MATERIAL_TEXTURE_SLOT_COUNT 8u
#define LDK_MATERIAL_ADDITIONAL_TEXTURE_COUNT 5u
typedef enum LDKMaterialTextureSlot{
LDK_MATERIAL_TEXTURE_SLOT_ALBEDO=0,
LDK_MATERIAL_TEXTURE_SLOT_NORMAL=1,
LDK_MATERIAL_TEXTURE_SLOT_SPECULAR=2,
LDK_MATERIAL_TEXTURE_SLOT_3=3,
LDK_MATERIAL_TEXTURE_SLOT_4=4,
LDK_MATERIAL_TEXTURE_SLOT_5=5,
LDK_MATERIAL_TEXTURE_SLOT_6=6,
LDK_MATERIAL_TEXTURE_SLOT_7=7
}LDKMaterialTextureSlot;
typedef struct LDKMaterialTextureSettings{
LDKMaterialTextureFilter filter;
LDKMaterialTextureMipFilter mip_filter;
LDKMaterialTextureWrap wrap_u;
LDKMaterialTextureWrap wrap_v;
Vec2 uv_scale;
Vec2 uv_offset;
bool independent;
}LDKMaterialTextureSettings;
typedef struct LDKMaterialTexturedArgs{
LDKAssetImage texture;
LDKMaterialTextureFilter filter;
LDKMaterialTextureMipFilter mip_filter;
LDKMaterialTextureWrap wrap_u;
LDKMaterialTextureWrap wrap_v;
Vec2 uv_scale;
Vec2 uv_offset;
rgba32 color;
}LDKMaterialTexturedArgs;
typedef struct LDKMaterialVertexColorArgs{
rgba32 color;
}LDKMaterialVertexColorArgs;
typedef union LDKMaterialArgs{
LDKMaterialTexturedArgs textured;
LDKMaterialVertexColorArgs vertex_color;
}LDKMaterialArgs;
typedef struct LDKMaterialSurfaceArgs{
float specular;
float shininess;
float emission;
LDKAssetImage normal_map;
LDKAssetImage specular_map;
}LDKMaterialSurfaceArgs;
typedef struct LDKMaterialDesc{
LDKMaterialType type;
LDKMaterialArgs args;
LDKMaterialSurfaceArgs surface;
LDKAssetImage additional_textures[LDK_MATERIAL_ADDITIONAL_TEXTURE_COUNT];
u32 texture_slot_mask;
LDKMaterialTextureSettings texture_settings[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
LDKAssetTextureAtlas texture_atlases[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
u64 texture_regions[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
LDKMaterialAlphaMode alpha_mode;
float alpha_cutoff;
}LDKMaterialDesc;
Check whether a value identifies a supported material type.
LDK_API bool ldk_material_type_is_valid(LDKMaterialType type);
LDKMaterialType typetrue for a supported material type, false otherwise.
Initialize a material descriptor with deterministic defaults. Every supported material type defaults to opaque white, opaque alpha mode, and a 0.5 cutout threshold. Textured materials also default to a null image asset, nearest filtering, no mip filtering, clamp-to-edge wrapping, and identity UV transform. Additional texture slots default to null. Lit materials default to no specular contribution, shininess 32, no emission, and no normal/specular maps. On failure, out_desc is reset to an invalid zero descriptor.
LDK_API bool ldk_material_desc_defaults(
LDKMaterialType type,
LDKMaterialDesc *out_desc
);
LDKMaterialType typeLDKMaterialDesc *out_desctrue on success, false for an invalid type or null destination.
Check whether a descriptor has a supported material type. This validates the descriptor structure only. Asset availability is validated later by the asset/material resolver. Textured cutout thresholds must be finite and within [0, 1]. Active lit surface values must be finite and non-negative. A zero shininess is canonicalized to the default value (32) so zero-initialized descriptors remain valid.
LDK_API bool ldk_material_desc_is_valid(LDKMaterialDesc const *desc);
LDKMaterialDesc const *desctrue when the descriptor is structurally valid.
Return the image assigned to a material texture slot.
LDK_API LDKAssetImage ldk_material_texture_slot_get(
LDKMaterialDesc const *desc,
u32 slot
);
LDKMaterialDesc const *descu32 slotHandle to the requested object or resource.
Assign an image to a material texture slot.
LDK_API bool ldk_material_texture_slot_set(
LDKMaterialDesc *desc,
u32 slot,
LDKAssetImage image
);
LDKMaterialDesc *descu32 slotLDKAssetImage imageTrue if the operation succeeds; false otherwise.
Assign an atlas region to a material slot; region 0 means full atlas.
LDK_API bool ldk_material_texture_atlas_set(
LDKMaterialDesc *desc,
u32 slot,
LDKAssetTextureAtlas atlas,
u64 region
);
LDKMaterialDesc *descu32 slotLDKAssetTextureAtlas atlasu64 regionTrue if the operation succeeds; false otherwise.
Return independent settings, or the legacy material defaults.
LDK_API LDKMaterialTextureSettings ldk_material_texture_settings_get(
LDKMaterialDesc const *desc,
u32 slot
);
LDKMaterialDesc const *descu32 slotThe requested value.
Compare the active values of two material descriptors exactly.
LDK_API bool ldk_material_desc_equal(
LDKMaterialDesc const *a,
LDKMaterialDesc const *b
);
LDKMaterialDesc const *aLDKMaterialDesc const *btrue when both descriptors represent the same authored material.
Hash the active values of a material descriptor.
LDK_API u64 ldk_material_desc_hash(LDKMaterialDesc const *desc);
LDKMaterialDesc const *descDeterministic hash, or zero for a null or invalid descriptor.