Kohi Game Engine
kmaterial_system.h File Reference

The material system is responsible for managing materials in the engine, including reference counting and auto-unloading. More...

#include "core_render_types.h"
#include <defines.h>
#include <strings/kname.h>

Go to the source code of this file.

Data Structures

struct  kmaterial_system_config
 The configuration for the material system. More...
 
struct  kmaterial_instance_data
 
struct  kmaterial_data
 

Macros

#define KMATERIAL_STANDARD_NAME_DEFAULT   "DefaultMaterial"
 
#define KMATERIAL_WATER_NAME_DEFAULT   "MaterialStandardWater"
 
#define KMATERIAL_BLENDED_NAME_DEFAULT   "MaterialStandardBlended"
 
#define KMATERIAL_MAX_IRRADIANCE_CUBEMAP_COUNT   4
 
#define KMATERIAL_MAX_SHADOW_CASCADES   4
 
#define KMATERIAL_MAX_WATER_PLANES   4
 
#define KMATERIAL_MAX_POINT_LIGHTS   10
 
#define KMATERIAL_DEFAULT_BASE_COLOUR_VALUE   (vec4){1.0f, 1.0f, 1.0f, 1.0f}
 
#define KMATERIAL_DEFAULT_NORMAL_VALUE   (vec3){0.0f, 0.0f, 1.0f}
 
#define KMATERIAL_DEFAULT_NORMAL_ENABLED   true
 
#define KMATERIAL_DEFAULT_METALLIC_VALUE   0.0f
 
#define KMATERIAL_DEFAULT_ROUGHNESS_VALUE   0.5f
 
#define KMATERIAL_DEFAULT_AO_VALUE   1.0f
 
#define KMATERIAL_DEFAULT_AO_ENABLED   true
 
#define KMATERIAL_DEFAULT_MRA_VALUE   (vec3){0.0f, 0.5f, 1.0f}
 
#define KMATERIAL_DEFAULT_MRA_ENABLED   true
 
#define KMATERIAL_DEFAULT_HAS_TRANSPARENCY   false
 
#define KMATERIAL_DEFAULT_MASKED   false
 
#define KMATERIAL_DEFAULT_DOUBLE_SIDED   false
 
#define KMATERIAL_DEFAULT_RECIEVES_SHADOW   true
 
#define KMATERIAL_DEFAULT_CASTS_SHADOW   true
 
#define KMATERIAL_DEFAULT_USE_VERTEX_COLOUR_AS_BASE_COLOUR   false
 

Typedefs

typedef struct kmaterial_system_config kmaterial_system_config
 The configuration for the material system. More...
 
typedef enum kmaterial_texture_input kmaterial_texture_input
 
typedef enum kmaterial_state kmaterial_state
 
typedef enum kmaterial_instance_state kmaterial_instance_state
 
typedef struct kmaterial_instance_data kmaterial_instance_data
 
typedef struct kmaterial_data kmaterial_data
 

Enumerations

enum  kmaterial_texture_input {
  KMATERIAL_TEXTURE_INPUT_BASE_COLOUR , KMATERIAL_TEXTURE_INPUT_NORMAL , KMATERIAL_TEXTURE_INPUT_METALLIC , KMATERIAL_TEXTURE_INPUT_ROUGHNESS ,
  KMATERIAL_TEXTURE_INPUT_AMBIENT_OCCLUSION , KMATERIAL_TEXTURE_INPUT_EMISSIVE , KMATERIAL_TEXTURE_INPUT_REFLECTION , KMATERIAL_TEXTURE_INPUT_REFRACTION ,
  KMATERIAL_TEXTURE_INPUT_REFLECTION_DEPTH , KMATERIAL_TEXTURE_INPUT_REFRACTION_DEPTH , KMATERIAL_TEXTURE_INPUT_DUDV , KMATERIAL_TEXTURE_INPUT_MRA ,
  KMATERIAL_TEXTURE_INPUT_COUNT
}
 
enum  kmaterial_state { KMATERIAL_STATE_UNINITIALIZED = 0 , KMATERIAL_STATE_LOADING , KMATERIAL_STATE_LOADED }
 
enum  kmaterial_instance_state { KMATERIAL_INSTANCE_STATE_UNINITIALIZED = 0 , KMATERIAL_INSTANCE_STATE_LOADING , KMATERIAL_INSTANCE_STATE_LOADED }
 

Functions

b8 kmaterial_system_initialize (u64 *memory_requirement, struct kmaterial_system_state *state, const kmaterial_system_config *config)
 Initializes the material system. Should be called twice; once to get the memory requirement (passing state=0), and a second time passing an allocated block of memory to actually initialize the system. More...
 
b8 kmaterial_system_setup_defaults (struct kmaterial_system_state *state)
 
void kmaterial_system_shutdown (struct kmaterial_system_state *state)
 Shuts down the material system. More...
 
KAPI b8 kmaterial_system_get_handle (struct kmaterial_system_state *state, kname name, kmaterial *out_material)
 Attempts to get the identifier of a material with the given name. If it has not yet been loaded, this triggers it to load. If the material is not found, a handle of the default material is returned. More...
 
KAPI b8 kmaterial_is_loaded_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI ktexture kmaterial_texture_get (struct kmaterial_system_state *state, kmaterial material, kmaterial_texture_input tex_input)
 
KAPI void kmaterial_texture_set (struct kmaterial_system_state *state, kmaterial material, kmaterial_texture_input tex_input, ktexture texture)
 
KAPI texture_channel kmaterial_metallic_texture_channel_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_metallic_texture_channel_set (struct kmaterial_system_state *state, kmaterial material, texture_channel value)
 
KAPI texture_channel kmaterial_roughness_texture_channel_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_roughness_texture_channel_set (struct kmaterial_system_state *state, kmaterial material, texture_channel value)
 
KAPI texture_channel kmaterial_ao_texture_channel_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_ao_texture_channel_set (struct kmaterial_system_state *state, kmaterial material, texture_channel value)
 
KAPI texture_filter kmaterial_texture_filter_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_texture_filter_set (struct kmaterial_system_state *state, kmaterial material, texture_filter value)
 
KAPI texture_repeat kmaterial_texture_mode_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_texture_mode_set (struct kmaterial_system_state *state, kmaterial material, texture_repeat value)
 
KAPI b8 kmaterial_has_transparency_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_has_transparency_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_double_sided_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_double_sided_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_recieves_shadow_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_recieves_shadow_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_casts_shadow_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_casts_shadow_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_normal_enabled_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_normal_enabled_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_ao_enabled_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_ao_enabled_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_emissive_enabled_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_emissive_enabled_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_refraction_enabled_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_refraction_enabled_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI f32 kmaterial_refraction_scale_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_refraction_scale_set (struct kmaterial_system_state *state, kmaterial material, f32 value)
 
KAPI b8 kmaterial_use_vertex_colour_as_base_colour_get (struct kmaterial_system_state *state, kmaterial material)
 
KAPI void kmaterial_use_vertex_colour_as_base_colour_set (struct kmaterial_system_state *state, kmaterial material, b8 value)
 
KAPI b8 kmaterial_flag_set (struct kmaterial_system_state *state, kmaterial material, kmaterial_flag_bits flag, b8 value)
 Sets the given material flag's state. More...
 
KAPI b8 kmaterial_flag_get (struct kmaterial_system_state *state, kmaterial material, kmaterial_flag_bits flag)
 Gets value of the given material flag's state. More...
 
KAPI b8 kmaterial_system_acquire (struct kmaterial_system_state *state, kname name, kmaterial_instance *out_instance)
 Attempts to acquire an instance of the material with the given handle. Increases internal reference count. More...
 
KAPI void kmaterial_system_release (struct kmaterial_system_state *state, kmaterial_instance *instance)
 Releases the given material instance. More...
 
KAPI const kmaterial_datakmaterial_get_base_material_data (struct kmaterial_system_state *state, kmaterial base_material)
 
KAPI const kmaterial_datakmaterial_system_get_all_base_materials (struct kmaterial_system_state *state)
 
KAPI const kmaterial_instance_datakmaterial_get_material_instance_data (struct kmaterial_system_state *state, kmaterial_instance instance)
 
KAPI b8 kmaterial_instance_flag_set (struct kmaterial_system_state *state, kmaterial_instance instance, kmaterial_flag_bits flag, b8 value)
 Sets the given material instance flag's state. More...
 
KAPI b8 kmaterial_instance_flag_get (struct kmaterial_system_state *state, kmaterial_instance instance, kmaterial_flag_bits flag)
 Gets value of the given material instance flag's state. More...
 
KAPI b8 kmaterial_instance_base_colour_get (struct kmaterial_system_state *state, kmaterial_instance instance, vec4 *out_value)
 Gets the value of the material instance-specific base colour. More...
 
KAPI b8 kmaterial_instance_base_colour_set (struct kmaterial_system_state *state, kmaterial_instance instance, vec4 value)
 Sets the value of the material instance-specific base colour. More...
 
KAPI b8 kmaterial_instance_uv_offset_get (struct kmaterial_system_state *state, kmaterial_instance instance, vec3 *out_value)
 Gets the value of the material instance-specific UV offset. Can be used for animating the position of materials. More...
 
KAPI b8 kmaterial_instance_uv_offset_set (struct kmaterial_system_state *state, kmaterial_instance instance, vec3 value)
 Sets the value of the material instance-specific UV offset. Can be used for animating the position of materials. More...
 
KAPI b8 kmaterial_instance_uv_scale_get (struct kmaterial_system_state *state, kmaterial_instance instance, vec3 *out_value)
 Gets the value of the material instance-specific UV scale. Can be used for animating the position of materials. More...
 
KAPI b8 kmaterial_instance_uv_scale_set (struct kmaterial_system_state *state, kmaterial_instance instance, vec3 value)
 Sets the value of the material instance-specific UV scale. Can be used for animating the position of materials. More...
 
KAPI kmaterial_instance kmaterial_system_get_default_standard (struct kmaterial_system_state *state)
 Gets an instance of the default standard material. More...
 
KAPI kmaterial_instance kmaterial_system_get_default_water (struct kmaterial_system_state *state)
 Gets an instance of the default water material. More...
 
KAPI kmaterial_instance kmaterial_system_get_default_blended (struct kmaterial_system_state *state)
 Gets an instance of the default blended material. More...
 
KAPI void kmaterial_system_dump (struct kmaterial_system_state *state)
 Dumps all of the registered materials and their reference counts/handles. More...
 

Detailed Description

The material system is responsible for managing materials in the engine, including reference counting and auto-unloading.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
2.0
Date
2026-01-06

Macro Definition Documentation

◆ KMATERIAL_BLENDED_NAME_DEFAULT

#define KMATERIAL_BLENDED_NAME_DEFAULT   "MaterialStandardBlended"

◆ KMATERIAL_DEFAULT_AO_ENABLED

#define KMATERIAL_DEFAULT_AO_ENABLED   true

◆ KMATERIAL_DEFAULT_AO_VALUE

#define KMATERIAL_DEFAULT_AO_VALUE   1.0f

◆ KMATERIAL_DEFAULT_BASE_COLOUR_VALUE

#define KMATERIAL_DEFAULT_BASE_COLOUR_VALUE   (vec4){1.0f, 1.0f, 1.0f, 1.0f}

◆ KMATERIAL_DEFAULT_CASTS_SHADOW

#define KMATERIAL_DEFAULT_CASTS_SHADOW   true

◆ KMATERIAL_DEFAULT_DOUBLE_SIDED

#define KMATERIAL_DEFAULT_DOUBLE_SIDED   false

◆ KMATERIAL_DEFAULT_HAS_TRANSPARENCY

#define KMATERIAL_DEFAULT_HAS_TRANSPARENCY   false

◆ KMATERIAL_DEFAULT_MASKED

#define KMATERIAL_DEFAULT_MASKED   false

◆ KMATERIAL_DEFAULT_METALLIC_VALUE

#define KMATERIAL_DEFAULT_METALLIC_VALUE   0.0f

◆ KMATERIAL_DEFAULT_MRA_ENABLED

#define KMATERIAL_DEFAULT_MRA_ENABLED   true

◆ KMATERIAL_DEFAULT_MRA_VALUE

#define KMATERIAL_DEFAULT_MRA_VALUE   (vec3){0.0f, 0.5f, 1.0f}

◆ KMATERIAL_DEFAULT_NORMAL_ENABLED

#define KMATERIAL_DEFAULT_NORMAL_ENABLED   true

◆ KMATERIAL_DEFAULT_NORMAL_VALUE

#define KMATERIAL_DEFAULT_NORMAL_VALUE   (vec3){0.0f, 0.0f, 1.0f}

◆ KMATERIAL_DEFAULT_RECIEVES_SHADOW

#define KMATERIAL_DEFAULT_RECIEVES_SHADOW   true

◆ KMATERIAL_DEFAULT_ROUGHNESS_VALUE

#define KMATERIAL_DEFAULT_ROUGHNESS_VALUE   0.5f

◆ KMATERIAL_DEFAULT_USE_VERTEX_COLOUR_AS_BASE_COLOUR

#define KMATERIAL_DEFAULT_USE_VERTEX_COLOUR_AS_BASE_COLOUR   false

◆ KMATERIAL_MAX_IRRADIANCE_CUBEMAP_COUNT

#define KMATERIAL_MAX_IRRADIANCE_CUBEMAP_COUNT   4

◆ KMATERIAL_MAX_POINT_LIGHTS

#define KMATERIAL_MAX_POINT_LIGHTS   10

◆ KMATERIAL_MAX_SHADOW_CASCADES

#define KMATERIAL_MAX_SHADOW_CASCADES   4

◆ KMATERIAL_MAX_WATER_PLANES

#define KMATERIAL_MAX_WATER_PLANES   4

◆ KMATERIAL_STANDARD_NAME_DEFAULT

#define KMATERIAL_STANDARD_NAME_DEFAULT   "DefaultMaterial"

◆ KMATERIAL_WATER_NAME_DEFAULT

#define KMATERIAL_WATER_NAME_DEFAULT   "MaterialStandardWater"

Typedef Documentation

◆ kmaterial_data

◆ kmaterial_instance_data

◆ kmaterial_instance_state

◆ kmaterial_state

◆ kmaterial_system_config

The configuration for the material system.

◆ kmaterial_texture_input

Enumeration Type Documentation

◆ kmaterial_instance_state

Enumerator
KMATERIAL_INSTANCE_STATE_UNINITIALIZED 
KMATERIAL_INSTANCE_STATE_LOADING 
KMATERIAL_INSTANCE_STATE_LOADED 

◆ kmaterial_state

Enumerator
KMATERIAL_STATE_UNINITIALIZED 
KMATERIAL_STATE_LOADING 
KMATERIAL_STATE_LOADED 

◆ kmaterial_texture_input

Enumerator
KMATERIAL_TEXTURE_INPUT_BASE_COLOUR 
KMATERIAL_TEXTURE_INPUT_NORMAL 
KMATERIAL_TEXTURE_INPUT_METALLIC 
KMATERIAL_TEXTURE_INPUT_ROUGHNESS 
KMATERIAL_TEXTURE_INPUT_AMBIENT_OCCLUSION 
KMATERIAL_TEXTURE_INPUT_EMISSIVE 
KMATERIAL_TEXTURE_INPUT_REFLECTION 
KMATERIAL_TEXTURE_INPUT_REFRACTION 
KMATERIAL_TEXTURE_INPUT_REFLECTION_DEPTH 
KMATERIAL_TEXTURE_INPUT_REFRACTION_DEPTH 
KMATERIAL_TEXTURE_INPUT_DUDV 
KMATERIAL_TEXTURE_INPUT_MRA 
KMATERIAL_TEXTURE_INPUT_COUNT 

Function Documentation

◆ kmaterial_ao_enabled_get()

KAPI b8 kmaterial_ao_enabled_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_ao_enabled_set()

KAPI void kmaterial_ao_enabled_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_ao_texture_channel_get()

KAPI texture_channel kmaterial_ao_texture_channel_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_ao_texture_channel_set()

KAPI void kmaterial_ao_texture_channel_set ( struct kmaterial_system_state *  state,
kmaterial  material,
texture_channel  value 
)

◆ kmaterial_casts_shadow_get()

KAPI b8 kmaterial_casts_shadow_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_casts_shadow_set()

KAPI void kmaterial_casts_shadow_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_double_sided_get()

KAPI b8 kmaterial_double_sided_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_double_sided_set()

KAPI void kmaterial_double_sided_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_emissive_enabled_get()

KAPI b8 kmaterial_emissive_enabled_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_emissive_enabled_set()

KAPI void kmaterial_emissive_enabled_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_flag_get()

KAPI b8 kmaterial_flag_get ( struct kmaterial_system_state *  state,
kmaterial  material,
kmaterial_flag_bits  flag 
)

Gets value of the given material flag's state.

Parameters
stateA pointer to the material system state.
materialThe identifier of the material.
material_flag_bitsThe flag whose value to get.
Returns
True if the flag is set; otherwise false.

◆ kmaterial_flag_set()

KAPI b8 kmaterial_flag_set ( struct kmaterial_system_state *  state,
kmaterial  material,
kmaterial_flag_bits  flag,
b8  value 
)

Sets the given material flag's state.

Parameters
stateA pointer to the material system state.
materialThe identifier of the material.
material_flag_bitsThe flag to set.
valueThe value of the flag.
Returns
True if successfully set; otherwise false.

◆ kmaterial_get_base_material_data()

KAPI const kmaterial_data* kmaterial_get_base_material_data ( struct kmaterial_system_state *  state,
kmaterial  base_material 
)

◆ kmaterial_get_material_instance_data()

KAPI const kmaterial_instance_data* kmaterial_get_material_instance_data ( struct kmaterial_system_state *  state,
kmaterial_instance  instance 
)

◆ kmaterial_has_transparency_get()

KAPI b8 kmaterial_has_transparency_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_has_transparency_set()

KAPI void kmaterial_has_transparency_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_instance_base_colour_get()

KAPI b8 kmaterial_instance_base_colour_get ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
vec4 out_value 
)

Gets the value of the material instance-specific base colour.

Parameters
stateA pointer to the material system state.
instanceThe material instance.
out_valueA pointer to hold the value. Required.
Returns
True if value was gotten successfully; otherwise false.

◆ kmaterial_instance_base_colour_set()

KAPI b8 kmaterial_instance_base_colour_set ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
vec4  value 
)

Sets the value of the material instance-specific base colour.

Parameters
stateA pointer to the material system state.
instanceThe material instance.
valueThe value to be set.
Returns
True if value was set successfully; otherwise false.

◆ kmaterial_instance_flag_get()

KAPI b8 kmaterial_instance_flag_get ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
kmaterial_flag_bits  flag 
)

Gets value of the given material instance flag's state.

Parameters
stateA pointer to the material system state.
instanceThe material instance.
material_flag_bitsThe flag whose value to get.
Returns
True if the flag is set; otherwise false.

◆ kmaterial_instance_flag_set()

KAPI b8 kmaterial_instance_flag_set ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
kmaterial_flag_bits  flag,
b8  value 
)

Sets the given material instance flag's state.

Parameters
stateA pointer to the material system state.
instanceThe the material instance.
material_flag_bitsThe flag to set.
valueThe value of the flag.
Returns
True if successfully set; otherwise false.

◆ kmaterial_instance_uv_offset_get()

KAPI b8 kmaterial_instance_uv_offset_get ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
vec3 out_value 
)

Gets the value of the material instance-specific UV offset. Can be used for animating the position of materials.

Parameters
stateA pointer to the material system state.
instanceThe material instance.
out_valueA pointer to hold the value. Required.
Returns
True if value was set successfully; otherwise false.

◆ kmaterial_instance_uv_offset_set()

KAPI b8 kmaterial_instance_uv_offset_set ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
vec3  value 
)

Sets the value of the material instance-specific UV offset. Can be used for animating the position of materials.

Parameters
stateA pointer to the material system state.
instanceThe material instance.
valueThe value to be set.
Returns
True if value was gotten successfully; otherwise false.

◆ kmaterial_instance_uv_scale_get()

KAPI b8 kmaterial_instance_uv_scale_get ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
vec3 out_value 
)

Gets the value of the material instance-specific UV scale. Can be used for animating the position of materials.

Parameters
stateA pointer to the material system state.
instanceThe material instance.
out_valueA pointer to hold the value. Required.
Returns
True if value was gotten successfully; otherwise false.

◆ kmaterial_instance_uv_scale_set()

KAPI b8 kmaterial_instance_uv_scale_set ( struct kmaterial_system_state *  state,
kmaterial_instance  instance,
vec3  value 
)

Sets the value of the material instance-specific UV scale. Can be used for animating the position of materials.

Parameters
stateA pointer to the material system state.
instanceThe material instance.
valueThe value to be set.
Returns
True if value was set successfully; otherwise false.

◆ kmaterial_is_loaded_get()

KAPI b8 kmaterial_is_loaded_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_metallic_texture_channel_get()

KAPI texture_channel kmaterial_metallic_texture_channel_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_metallic_texture_channel_set()

KAPI void kmaterial_metallic_texture_channel_set ( struct kmaterial_system_state *  state,
kmaterial  material,
texture_channel  value 
)

◆ kmaterial_normal_enabled_get()

KAPI b8 kmaterial_normal_enabled_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_normal_enabled_set()

KAPI void kmaterial_normal_enabled_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_recieves_shadow_get()

KAPI b8 kmaterial_recieves_shadow_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_recieves_shadow_set()

KAPI void kmaterial_recieves_shadow_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_refraction_enabled_get()

KAPI b8 kmaterial_refraction_enabled_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_refraction_enabled_set()

KAPI void kmaterial_refraction_enabled_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)

◆ kmaterial_refraction_scale_get()

KAPI f32 kmaterial_refraction_scale_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_refraction_scale_set()

KAPI void kmaterial_refraction_scale_set ( struct kmaterial_system_state *  state,
kmaterial  material,
f32  value 
)

◆ kmaterial_roughness_texture_channel_get()

KAPI texture_channel kmaterial_roughness_texture_channel_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_roughness_texture_channel_set()

KAPI void kmaterial_roughness_texture_channel_set ( struct kmaterial_system_state *  state,
kmaterial  material,
texture_channel  value 
)

◆ kmaterial_system_acquire()

KAPI b8 kmaterial_system_acquire ( struct kmaterial_system_state *  state,
kname  name,
kmaterial_instance out_instance 
)

Attempts to acquire an instance of the material with the given handle. Increases internal reference count.

Parameters
stateA pointer to the material system state.
nameThe name of the material to acquire an instance for.
out_instanceA pointer to hold the acquired material instance. Required.
Returns
True on success; otherwise false.

◆ kmaterial_system_dump()

KAPI void kmaterial_system_dump ( struct kmaterial_system_state *  state)

Dumps all of the registered materials and their reference counts/handles.

Parameters
stateA pointer to the material system state.

◆ kmaterial_system_get_all_base_materials()

KAPI const kmaterial_data* kmaterial_system_get_all_base_materials ( struct kmaterial_system_state *  state)

◆ kmaterial_system_get_default_blended()

KAPI kmaterial_instance kmaterial_system_get_default_blended ( struct kmaterial_system_state *  state)

Gets an instance of the default blended material.

Parameters
stateA pointer to the material system state.
Returns
A material instance with handles to the material and instance of it.

◆ kmaterial_system_get_default_standard()

KAPI kmaterial_instance kmaterial_system_get_default_standard ( struct kmaterial_system_state *  state)

Gets an instance of the default standard material.

Parameters
stateA pointer to the material system state.
Returns
A material instance with handles to the material and instance of it.

◆ kmaterial_system_get_default_water()

KAPI kmaterial_instance kmaterial_system_get_default_water ( struct kmaterial_system_state *  state)

Gets an instance of the default water material.

Parameters
stateA pointer to the material system state.
Returns
A material instance with handles to the material and instance of it.

◆ kmaterial_system_get_handle()

KAPI b8 kmaterial_system_get_handle ( struct kmaterial_system_state *  state,
kname  name,
kmaterial out_material 
)

Attempts to get the identifier of a material with the given name. If it has not yet been loaded, this triggers it to load. If the material is not found, a handle of the default material is returned.

Parameters
stateA pointer to the material system state.
nameThe name of the material to get the identifier of.
out_material_handleA pointer to hold the material handle.
Returns
True if the material was found; otherwise false if the default material was returned.

◆ kmaterial_system_initialize()

b8 kmaterial_system_initialize ( u64 memory_requirement,
struct kmaterial_system_state *  state,
const kmaterial_system_config config 
)

Initializes the material system. Should be called twice; once to get the memory requirement (passing state=0), and a second time passing an allocated block of memory to actually initialize the system.

Parameters
memory_requirementA pointer to hold the memory requirement as it is calculated.
stateA block of memory to hold the state or, if gathering the memory requirement, 0.
configThe configuration (material_system_config) for this system.
Returns
True on success; otherwise false.

◆ kmaterial_system_release()

KAPI void kmaterial_system_release ( struct kmaterial_system_state *  state,
kmaterial_instance instance 
)

Releases the given material instance.

Parameters
stateA pointer to the material system state.
instanceA pointer to the material instance to unload. Handles are invalidated. Required.

◆ kmaterial_system_setup_defaults()

b8 kmaterial_system_setup_defaults ( struct kmaterial_system_state *  state)

◆ kmaterial_system_shutdown()

void kmaterial_system_shutdown ( struct kmaterial_system_state *  state)

Shuts down the material system.

Parameters
stateThe state block of memory.

◆ kmaterial_texture_filter_get()

KAPI texture_filter kmaterial_texture_filter_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_texture_filter_set()

KAPI void kmaterial_texture_filter_set ( struct kmaterial_system_state *  state,
kmaterial  material,
texture_filter  value 
)

◆ kmaterial_texture_get()

KAPI ktexture kmaterial_texture_get ( struct kmaterial_system_state *  state,
kmaterial  material,
kmaterial_texture_input  tex_input 
)

◆ kmaterial_texture_mode_get()

KAPI texture_repeat kmaterial_texture_mode_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_texture_mode_set()

KAPI void kmaterial_texture_mode_set ( struct kmaterial_system_state *  state,
kmaterial  material,
texture_repeat  value 
)

◆ kmaterial_texture_set()

KAPI void kmaterial_texture_set ( struct kmaterial_system_state *  state,
kmaterial  material,
kmaterial_texture_input  tex_input,
ktexture  texture 
)

◆ kmaterial_use_vertex_colour_as_base_colour_get()

KAPI b8 kmaterial_use_vertex_colour_as_base_colour_get ( struct kmaterial_system_state *  state,
kmaterial  material 
)

◆ kmaterial_use_vertex_colour_as_base_colour_set()

KAPI void kmaterial_use_vertex_colour_as_base_colour_set ( struct kmaterial_system_state *  state,
kmaterial  material,
b8  value 
)