Struct in ldk_renderer.h

LDKRendererMaterialDesc

typedef struct LDKRendererMaterialDesc{
  LDKMaterialType type;
  LDKResourceTexture texture;
  LDKResourceTexture normal_map;
  LDKResourceTexture specular_map;
  LDKResourceTexture additional_textures[LDK_MATERIAL_ADDITIONAL_TEXTURE_COUNT];
  rgba32 color;
  LDKMaterialAlphaMode alpha_mode;
  float alpha_cutoff;
  float specular;
  float shininess;
  float emission;
  float vegetation_curvature;
  float vegetation_wind_strength;
  float vegetation_wind_speed;
  float vegetation_wind_direction;
  float vegetation_interaction_recovery_time;
  bool vegetation;
  bool terrain;
  u32 terrain_surface_count;
  LDKRendererTerrainSurfaceDesc terrain_surfaces[LDK_RENDERER_TERRAIN_SURFACE_COUNT];
}LDKRendererMaterialDesc;
Struct in ldk_renderer.h

LDKRendererMaterialResource

typedef struct LDKRendererMaterialResource{
  LDKRendererMaterialDesc desc;
  LDKRendererMaterialSelection selection;
  LDKRendererRenderKey render_key;
  LDKRHISampler texture_sampler;
  LDKRHISampler texture_samplers[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
  Vec2 texture_uv_scales[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
  Vec2 texture_uv_offsets[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
  bool owns_additional_textures;
  u32 ref_count;
  const struct LDKAssetManager *source_assets;
  LDKMaterialDesc source_desc;
  bool has_source_desc;
  u64 source_atlas_revisions[LDK_MATERIAL_TEXTURE_SLOT_COUNT];
  Vec2 uv_scale;
  Vec2 uv_offset;
  bool alive;
}LDKRendererMaterialResource;
Enum in ldk_renderer.h

LDKRendererMaterialSelection

typedef enum LDKRendererMaterialSelection{
  LDK_RENDERER_MATERIAL_SELECTION_INVALID=0,
  LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_UNLIT,
  LDK_RENDERER_MATERIAL_SELECTION_TEXTURED,
  LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR_UNLIT,
  LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR,
  LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR_UNLIT_BLEND,
  LDK_RENDERER_MATERIAL_SELECTION_VERTEX_COLOR_BLEND,
  LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_UNLIT_CUTOUT,
  LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_CUTOUT,
  LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_UNLIT_BLEND,
  LDK_RENDERER_MATERIAL_SELECTION_TEXTURED_BLEND,
  LDK_RENDERER_MATERIAL_SELECTION_VEGETATION,
  LDK_RENDERER_MATERIAL_SELECTION_TERRAIN
}LDKRendererMaterialSelection;
Function in ldk_renderer.h

ldk_renderer_material_atlases_current

Test whether a resolved material still matches its atlas revisions. A changed atlas may have a different backing image or region geometry.

LDK_API bool ldk_renderer_material_atlases_current(
 LDKRenderer *renderer,
 struct LDKAssetManager *assets,
 LDKResourceMaterial material
);

Parameters

LDKRenderer *renderer
Renderer receiving this request.
struct LDKAssetManager *assets
Asset manager used to resolve referenced assets.
LDKResourceMaterial material
Material used by the operation.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_renderer.h

ldk_renderer_material_create

Create a renderer-owned material resource. Textured materials require a live renderer texture. The referenced texture must remain alive until the material is destroyed. Textured materials may use opaque or cutout alpha mode; cutout thresholds must be finite and in [0, 1]. Lit normal/specular maps and shader-defined slots 3..7 are optional borrowed texture resources and must remain alive while the material exists; null map handles use renderer-owned neutral fallbacks. Vertex-color materials ignore texture and alpha fields. Unlit materials ignore map handles. Lit surface values must be finite and non-negative. A zero shininess uses the default value (32).

LDK_API LDKResourceMaterial ldk_renderer_material_create(
 LDKRenderer *renderer,
 LDKRendererMaterialDesc const *desc
);

Parameters

LDKRenderer *renderer
Renderer that will own the material resource.
LDKRendererMaterialDesc const *desc
Resolved renderer material description.

Returns

New material handle, or an invalid handle on failure.

Function in ldk_renderer.h

ldk_renderer_material_default_get

Return the renderer-owned default mesh material. The default material is a white vertex-color material created during renderer initialization and destroyed during renderer termination.

LDK_API LDKResourceMaterial ldk_renderer_material_default_get(LDKRenderer *renderer);

Parameters

LDKRenderer *renderer
Renderer that owns the default material.

Returns

Default material handle, or an invalid handle when unavailable.

Function in ldk_renderer.h

ldk_renderer_material_destroy

Destroy a renderer-owned material resource. Destroying an invalid or already-dead material is a no-op. Material resources are also destroyed automatically when the renderer terminates.

LDK_API void ldk_renderer_material_destroy(
 LDKRenderer *renderer,
 LDKResourceMaterial material
);

Parameters

LDKRenderer *renderer
Renderer that owns the material resource.
LDKResourceMaterial material
Material resource to destroy.
Function in ldk_renderer.h

ldk_renderer_material_null

Return an invalid material resource handle.

LDK_API LDKResourceMaterial ldk_renderer_material_null(void);

Returns

Invalid material resource handle.

Function in ldk_renderer.h

ldk_renderer_material_resolve

Resolve an authored material description into renderer resources. Textured materials acquire a shared renderer texture from the supplied asset manager. If the authored image is unavailable, the renderer uses the shared missing-image fallback. Shader-defined slots 3..7 are acquired the same way and are owned by the resolved material. Lit normal/specular maps are acquired when available; missing maps resolve to renderer-owned neutral fallbacks. Existing output resources are replaced only after the new material has been created successfully. The caller owns the returned material resource and one acquisition of each non-null returned image texture. A later successful resolve replaces those resources. Additional slots 3..7 are released by material destruction. The caller must destroy/release the remaining resources when its owner terminates.

LDK_API bool ldk_renderer_material_resolve(
 LDKRenderer *renderer,
 struct LDKAssetManager *assets,
 LDKMaterialDesc const *material_desc,
 LDKResourceMaterial *renderer_material,
 LDKResourceTexture *renderer_texture,
 LDKResourceTexture *renderer_normal_map,
 LDKResourceTexture *renderer_specular_map
);

Parameters

LDKRenderer *renderer
Renderer that owns the runtime resources.
struct LDKAssetManager *assets
Asset manager used to resolve authored image assets. Required for textured materials and for lit materials that reference maps.
LDKMaterialDesc const *material_desc
Authored material description.
LDKResourceMaterial *renderer_material
In/out renderer material resource.
LDKResourceTexture *renderer_texture
In/out acquired albedo texture resource.
LDKResourceTexture *renderer_normal_map
In/out acquired normal-map texture resource.
LDKResourceTexture *renderer_specular_map
In/out acquired specular-map texture resource.

Returns

true when the material was resolved successfully.

Function in ldk_renderer.h

ldk_renderer_terrain_material_resolve

Resolve a normal authored material using TerrainSystem surface rules.

LDK_API bool ldk_renderer_terrain_material_resolve(
 LDKRenderer *renderer,
 struct LDKAssetManager *assets,
 LDKMaterialDesc const *material_desc,
 const LDKRendererTerrainSurfaceDesc *surfaces,
 u32 surface_count,
 LDKResourceMaterial *renderer_material,
 LDKResourceTexture *renderer_texture,
 LDKResourceTexture *renderer_normal_map,
 LDKResourceTexture *renderer_specular_map
);

Parameters

LDKRenderer *renderer
Renderer receiving this request.
struct LDKAssetManager *assets
Asset manager used to resolve referenced assets.
LDKMaterialDesc const *material_desc
Material desc used by this operation.
const LDKRendererTerrainSurfaceDesc *surfaces
Surfaces used by this operation.
u32 surface_count
Number of surface entries.
LDKResourceMaterial *renderer_material
Renderer material used by this operation.
LDKResourceTexture *renderer_texture
Renderer texture used by this operation.
LDKResourceTexture *renderer_normal_map
Renderer normal map used by this operation.
LDKResourceTexture *renderer_specular_map
Renderer specular map used by this operation.

Returns

True if the operation succeeds; false otherwise.