|
Kohi Game Engine
|
The material system is responsible for managing materials in the engine, including reference counting and auto-unloading. More...
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 |
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 |
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_data * | kmaterial_get_base_material_data (struct kmaterial_system_state *state, kmaterial base_material) |
| KAPI const kmaterial_data * | kmaterial_system_get_all_base_materials (struct kmaterial_system_state *state) |
| KAPI const kmaterial_instance_data * | kmaterial_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... | |
The material system is responsible for managing materials in the engine, including reference counting and auto-unloading.
| #define KMATERIAL_BLENDED_NAME_DEFAULT "MaterialStandardBlended" |
| #define KMATERIAL_DEFAULT_AO_ENABLED true |
| #define KMATERIAL_DEFAULT_AO_VALUE 1.0f |
| #define KMATERIAL_DEFAULT_BASE_COLOUR_VALUE (vec4){1.0f, 1.0f, 1.0f, 1.0f} |
| #define KMATERIAL_DEFAULT_CASTS_SHADOW true |
| #define KMATERIAL_DEFAULT_DOUBLE_SIDED false |
| #define KMATERIAL_DEFAULT_HAS_TRANSPARENCY false |
| #define KMATERIAL_DEFAULT_MASKED false |
| #define KMATERIAL_DEFAULT_METALLIC_VALUE 0.0f |
| #define KMATERIAL_DEFAULT_MRA_ENABLED true |
| #define KMATERIAL_DEFAULT_MRA_VALUE (vec3){0.0f, 0.5f, 1.0f} |
| #define KMATERIAL_DEFAULT_NORMAL_ENABLED true |
| #define KMATERIAL_DEFAULT_NORMAL_VALUE (vec3){0.0f, 0.0f, 1.0f} |
| #define KMATERIAL_DEFAULT_RECIEVES_SHADOW true |
| #define KMATERIAL_DEFAULT_ROUGHNESS_VALUE 0.5f |
| #define KMATERIAL_DEFAULT_USE_VERTEX_COLOUR_AS_BASE_COLOUR false |
| #define KMATERIAL_MAX_IRRADIANCE_CUBEMAP_COUNT 4 |
| #define KMATERIAL_MAX_POINT_LIGHTS 10 |
| #define KMATERIAL_MAX_SHADOW_CASCADES 4 |
| #define KMATERIAL_MAX_WATER_PLANES 4 |
| #define KMATERIAL_STANDARD_NAME_DEFAULT "DefaultMaterial" |
| #define KMATERIAL_WATER_NAME_DEFAULT "MaterialStandardWater" |
| typedef struct kmaterial_data kmaterial_data |
| typedef struct kmaterial_instance_data kmaterial_instance_data |
| typedef enum kmaterial_instance_state kmaterial_instance_state |
| typedef enum kmaterial_state kmaterial_state |
| typedef struct kmaterial_system_config kmaterial_system_config |
The configuration for the material system.
| typedef enum kmaterial_texture_input kmaterial_texture_input |
| enum kmaterial_state |
| KAPI void kmaterial_ao_enabled_set | ( | struct kmaterial_system_state * | state, |
| kmaterial | material, | ||
| b8 | 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 void kmaterial_casts_shadow_set | ( | struct kmaterial_system_state * | state, |
| kmaterial | material, | ||
| b8 | value | ||
| ) |
| KAPI void kmaterial_double_sided_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_flag_get | ( | struct kmaterial_system_state * | state, |
| kmaterial | material, | ||
| kmaterial_flag_bits | flag | ||
| ) |
Gets value of the given material flag's state.
| state | A pointer to the material system state. |
| material | The identifier of the material. |
| material_flag_bits | The flag whose value to get. |
| 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.
| state | A pointer to the material system state. |
| material | The identifier of the material. |
| material_flag_bits | The flag to set. |
| value | The value of the flag. |
| KAPI const kmaterial_data* kmaterial_get_base_material_data | ( | struct kmaterial_system_state * | state, |
| kmaterial | base_material | ||
| ) |
| KAPI const kmaterial_instance_data* kmaterial_get_material_instance_data | ( | struct kmaterial_system_state * | state, |
| kmaterial_instance | instance | ||
| ) |
| 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_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.
| state | A pointer to the material system state. |
| instance | The material instance. |
| out_value | A pointer to hold the value. Required. |
| 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.
| state | A pointer to the material system state. |
| instance | The material instance. |
| value | The value to be set. |
| 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.
| state | A pointer to the material system state. |
| instance | The material instance. |
| material_flag_bits | The flag whose value to get. |
| 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.
| state | A pointer to the material system state. |
| instance | The the material instance. |
| material_flag_bits | The flag to set. |
| value | The value of the flag. |
| 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.
| state | A pointer to the material system state. |
| instance | The material instance. |
| out_value | A pointer to hold the value. Required. |
| 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.
| state | A pointer to the material system state. |
| instance | The material instance. |
| value | The value to be set. |
| 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.
| state | A pointer to the material system state. |
| instance | The material instance. |
| out_value | A pointer to hold the value. Required. |
| 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.
| state | A pointer to the material system state. |
| instance | The material instance. |
| value | The value to be set. |
| 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 void kmaterial_normal_enabled_set | ( | struct kmaterial_system_state * | state, |
| kmaterial | material, | ||
| b8 | value | ||
| ) |
| KAPI void kmaterial_recieves_shadow_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 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 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.
| state | A pointer to the material system state. |
| name | The name of the material to acquire an instance for. |
| out_instance | A pointer to hold the acquired material instance. Required. |
| KAPI void kmaterial_system_dump | ( | struct kmaterial_system_state * | state | ) |
Dumps all of the registered materials and their reference counts/handles.
| state | A pointer to the material system state. |
| KAPI const kmaterial_data* kmaterial_system_get_all_base_materials | ( | struct kmaterial_system_state * | state | ) |
| KAPI kmaterial_instance kmaterial_system_get_default_blended | ( | struct kmaterial_system_state * | state | ) |
Gets an instance of the default blended material.
| state | A pointer to the material system state. |
| KAPI kmaterial_instance kmaterial_system_get_default_standard | ( | struct kmaterial_system_state * | state | ) |
Gets an instance of the default standard material.
| state | A pointer to the material system state. |
| KAPI kmaterial_instance kmaterial_system_get_default_water | ( | struct kmaterial_system_state * | state | ) |
Gets an instance of the default water material.
| state | A pointer to the material system state. |
| 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.
| state | A pointer to the material system state. |
| name | The name of the material to get the identifier of. |
| out_material_handle | A pointer to hold the material handle. |
| 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.
| memory_requirement | A pointer to hold the memory requirement as it is calculated. |
| state | A block of memory to hold the state or, if gathering the memory requirement, 0. |
| config | The configuration (material_system_config) for this system. |
| KAPI void kmaterial_system_release | ( | struct kmaterial_system_state * | state, |
| kmaterial_instance * | instance | ||
| ) |
Releases the given material instance.
| state | A pointer to the material system state. |
| instance | A pointer to the material instance to unload. Handles are invalidated. Required. |
| b8 kmaterial_system_setup_defaults | ( | struct kmaterial_system_state * | state | ) |
| void kmaterial_system_shutdown | ( | struct kmaterial_system_state * | state | ) |
Shuts down the material system.
| state | The state block of memory. |
| 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 ktexture kmaterial_texture_get | ( | struct kmaterial_system_state * | state, |
| kmaterial | material, | ||
| kmaterial_texture_input | tex_input | ||
| ) |
| 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 void kmaterial_texture_set | ( | struct kmaterial_system_state * | state, |
| kmaterial | material, | ||
| kmaterial_texture_input | tex_input, | ||
| ktexture | texture | ||
| ) |
| KAPI b8 kmaterial_use_vertex_colour_as_base_colour_get | ( | struct kmaterial_system_state * | state, |
| kmaterial | material | ||
| ) |