Kohi Game Engine
|
The material system is responsible for managing materials in the engine, including reference counting and auto-unloading. More...
#include "core_render_types.h"
#include "identifiers/khandle.h"
#include "kresources/kresource_types.h"
#include <defines.h>
#include <strings/kname.h>
Go to the source code of this file.
Data Structures | |
struct | material_system_config |
The configuration for the material system. More... | |
struct | material_frame_data |
struct | material_instance_draw_data |
Typedefs | |
typedef struct material_system_config | material_system_config |
The configuration for the material system. More... | |
typedef enum material_texture_input | material_texture_input |
typedef struct material_frame_data | material_frame_data |
typedef struct material_instance_draw_data | material_instance_draw_data |
Functions | |
b8 | material_system_initialize (u64 *memory_requirement, struct material_system_state *state, const material_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... | |
void | material_system_shutdown (struct material_system_state *state) |
Shuts down the material system. More... | |
KAPI b8 | material_system_get_handle (struct material_system_state *state, kname name, khandle *out_material_handle) |
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 | material_is_loaded_get (struct material_system_state *state, khandle material) |
KAPI ktexture | material_texture_get (struct material_system_state *state, khandle material, material_texture_input tex_input) |
KAPI void | material_texture_set (struct material_system_state *state, khandle material, material_texture_input tex_input, ktexture texture) |
KAPI texture_channel | material_metallic_texture_channel_get (struct material_system_state *state, khandle material) |
KAPI void | material_metallic_texture_channel_set (struct material_system_state *state, khandle material, texture_channel value) |
KAPI texture_channel | material_roughness_texture_channel_get (struct material_system_state *state, khandle material) |
KAPI void | material_roughness_texture_channel_set (struct material_system_state *state, khandle material, texture_channel value) |
KAPI texture_channel | material_ao_texture_channel_get (struct material_system_state *state, khandle material) |
KAPI void | material_ao_texture_channel_set (struct material_system_state *state, khandle material, texture_channel value) |
KAPI texture_filter | material_texture_filter_get (struct material_system_state *state, khandle material) |
KAPI void | material_texture_filter_set (struct material_system_state *state, khandle material, texture_filter value) |
KAPI texture_repeat | material_texture_mode_get (struct material_system_state *state, khandle material) |
KAPI void | material_texture_mode_set (struct material_system_state *state, khandle material, texture_repeat value) |
KAPI b8 | material_has_transparency_get (struct material_system_state *state, khandle material) |
KAPI void | material_has_transparency_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_double_sided_get (struct material_system_state *state, khandle material) |
KAPI void | material_double_sided_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_recieves_shadow_get (struct material_system_state *state, khandle material) |
KAPI void | material_recieves_shadow_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_casts_shadow_get (struct material_system_state *state, khandle material) |
KAPI void | material_casts_shadow_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_normal_enabled_get (struct material_system_state *state, khandle material) |
KAPI void | material_normal_enabled_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_ao_enabled_get (struct material_system_state *state, khandle material) |
KAPI void | material_ao_enabled_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_emissive_enabled_get (struct material_system_state *state, khandle material) |
KAPI void | material_emissive_enabled_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_refraction_enabled_get (struct material_system_state *state, khandle material) |
KAPI void | material_refraction_enabled_set (struct material_system_state *state, khandle material, b8 value) |
KAPI f32 | material_refraction_scale_get (struct material_system_state *state, khandle material) |
KAPI void | material_refraction_scale_set (struct material_system_state *state, khandle material, f32 value) |
KAPI b8 | material_use_vertex_colour_as_base_colour_get (struct material_system_state *state, khandle material) |
KAPI void | material_use_vertex_colour_as_base_colour_set (struct material_system_state *state, khandle material, b8 value) |
KAPI b8 | material_flag_set (struct material_system_state *state, khandle material, kmaterial_flag_bits flag, b8 value) |
Sets the given material flag's state. More... | |
KAPI b8 | material_flag_get (struct material_system_state *state, khandle material, kmaterial_flag_bits flag) |
Gets value of the given material flag's state. More... | |
KAPI b8 | material_system_acquire (struct material_system_state *state, kname name, material_instance *out_instance) |
Attempts to acquire an instance of the material with the given handle. Increases internal reference count. More... | |
KAPI void | material_system_release (struct material_system_state *state, material_instance *instance) |
Releases the given material instance. More... | |
b8 | material_system_prepare_frame (struct material_system_state *state, material_frame_data mat_frame_data, struct frame_data *p_frame_data) |
b8 | material_system_apply (struct material_system_state *state, khandle material, struct frame_data *p_frame_data) |
b8 | material_system_apply_instance (struct material_system_state *state, const material_instance *instance, struct material_instance_draw_data draw_data, struct frame_data *p_frame_data) |
KAPI b8 | material_instance_flag_set (struct material_system_state *state, material_instance instance, kmaterial_flag_bits flag, b8 value) |
Sets the given material instance flag's state. More... | |
KAPI b8 | material_instance_flag_get (struct material_system_state *state, material_instance instance, kmaterial_flag_bits flag) |
Gets value of the given material instance flag's state. More... | |
KAPI b8 | material_instance_base_colour_get (struct material_system_state *state, material_instance instance, vec4 *out_value) |
Gets the value of the material instance-specific base colour. More... | |
KAPI b8 | material_instance_base_colour_set (struct material_system_state *state, material_instance instance, vec4 value) |
Sets the value of the material instance-specific base colour. More... | |
KAPI b8 | material_instance_uv_offset_get (struct material_system_state *state, material_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 | material_instance_uv_offset_set (struct material_system_state *state, material_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 | material_instance_uv_scale_get (struct material_system_state *state, material_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 | material_instance_uv_scale_set (struct material_system_state *state, material_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 material_instance | material_system_get_default_standard (struct material_system_state *state) |
Gets an instance of the default standard material. More... | |
KAPI material_instance | material_system_get_default_water (struct material_system_state *state) |
Gets an instance of the default water material. More... | |
KAPI material_instance | material_system_get_default_blended (struct material_system_state *state) |
Gets an instance of the default blended material. More... | |
KAPI void | material_system_dump (struct material_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 MATERIAL_DEFAULT_AO_ENABLED true |
#define MATERIAL_DEFAULT_AO_VALUE 1.0f |
#define MATERIAL_DEFAULT_BASE_COLOUR_VALUE (vec4){1.0f, 1.0f, 1.0f, 1.0f} |
#define MATERIAL_DEFAULT_CASTS_SHADOW true |
#define MATERIAL_DEFAULT_DOUBLE_SIDED false |
#define MATERIAL_DEFAULT_HAS_TRANSPARENCY false |
#define MATERIAL_DEFAULT_METALLIC_VALUE 0.0f |
#define MATERIAL_DEFAULT_MRA_ENABLED true |
#define MATERIAL_DEFAULT_MRA_VALUE (vec3){0.0f, 0.5f, 1.0f} |
#define MATERIAL_DEFAULT_NAME_BLENDED "Material.DefaultBlended" |
#define MATERIAL_DEFAULT_NAME_STANDARD "Material.DefaultStandard" |
#define MATERIAL_DEFAULT_NAME_WATER "Material.DefaultWater" |
#define MATERIAL_DEFAULT_NORMAL_ENABLED true |
#define MATERIAL_DEFAULT_NORMAL_VALUE (vec3){0.0f, 0.0f, 1.0f} |
#define MATERIAL_DEFAULT_RECIEVES_SHADOW true |
#define MATERIAL_DEFAULT_ROUGHNESS_VALUE 0.5f |
#define MATERIAL_DEFAULT_USE_VERTEX_COLOUR_AS_BASE_COLOUR false |
#define MATERIAL_MAX_IRRADIANCE_CUBEMAP_COUNT 4 |
#define MATERIAL_MAX_POINT_LIGHTS 10 |
#define MATERIAL_MAX_SHADOW_CASCADES 4 |
#define MATERIAL_MAX_VIEWS 4 |
typedef struct material_frame_data material_frame_data |
Holds internal state for per-frame data (i.e across all standard materials);
typedef struct material_instance_draw_data material_instance_draw_data |
typedef struct material_system_config material_system_config |
The configuration for the material system.
typedef enum material_texture_input material_texture_input |
KAPI void material_ao_enabled_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI texture_channel material_ao_texture_channel_get | ( | struct material_system_state * | state, |
khandle | material | ||
) |
KAPI void material_ao_texture_channel_set | ( | struct material_system_state * | state, |
khandle | material, | ||
texture_channel | value | ||
) |
KAPI void material_casts_shadow_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI void material_double_sided_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI void material_emissive_enabled_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI b8 material_flag_get | ( | struct material_system_state * | state, |
khandle | 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 material_flag_set | ( | struct material_system_state * | state, |
khandle | 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 void material_has_transparency_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI b8 material_instance_base_colour_get | ( | struct material_system_state * | state, |
material_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 material_instance_base_colour_set | ( | struct material_system_state * | state, |
material_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 material_instance_flag_get | ( | struct material_system_state * | state, |
material_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 material_instance_flag_set | ( | struct material_system_state * | state, |
material_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 material_instance_uv_offset_get | ( | struct material_system_state * | state, |
material_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 material_instance_uv_offset_set | ( | struct material_system_state * | state, |
material_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 material_instance_uv_scale_get | ( | struct material_system_state * | state, |
material_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 material_instance_uv_scale_set | ( | struct material_system_state * | state, |
material_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 material_metallic_texture_channel_get | ( | struct material_system_state * | state, |
khandle | material | ||
) |
KAPI void material_metallic_texture_channel_set | ( | struct material_system_state * | state, |
khandle | material, | ||
texture_channel | value | ||
) |
KAPI void material_normal_enabled_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI void material_recieves_shadow_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI void material_refraction_enabled_set | ( | struct material_system_state * | state, |
khandle | material, | ||
b8 | value | ||
) |
KAPI void material_refraction_scale_set | ( | struct material_system_state * | state, |
khandle | material, | ||
f32 | value | ||
) |
KAPI texture_channel material_roughness_texture_channel_get | ( | struct material_system_state * | state, |
khandle | material | ||
) |
KAPI void material_roughness_texture_channel_set | ( | struct material_system_state * | state, |
khandle | material, | ||
texture_channel | value | ||
) |
KAPI b8 material_system_acquire | ( | struct material_system_state * | state, |
kname | name, | ||
material_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. |
b8 material_system_apply | ( | struct material_system_state * | state, |
khandle | material, | ||
struct frame_data * | p_frame_data | ||
) |
b8 material_system_apply_instance | ( | struct material_system_state * | state, |
const material_instance * | instance, | ||
struct material_instance_draw_data | draw_data, | ||
struct frame_data * | p_frame_data | ||
) |
KAPI void material_system_dump | ( | struct material_system_state * | state | ) |
Dumps all of the registered materials and their reference counts/handles.
state | A pointer to the material system state. |
KAPI material_instance material_system_get_default_blended | ( | struct material_system_state * | state | ) |
Gets an instance of the default blended material.
state | A pointer to the material system state. |
KAPI material_instance material_system_get_default_standard | ( | struct material_system_state * | state | ) |
Gets an instance of the default standard material.
state | A pointer to the material system state. |
KAPI material_instance material_system_get_default_water | ( | struct material_system_state * | state | ) |
Gets an instance of the default water material.
state | A pointer to the material system state. |
KAPI b8 material_system_get_handle | ( | struct material_system_state * | state, |
kname | name, | ||
khandle * | out_material_handle | ||
) |
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 material_system_initialize | ( | u64 * | memory_requirement, |
struct material_system_state * | state, | ||
const material_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. |
b8 material_system_prepare_frame | ( | struct material_system_state * | state, |
material_frame_data | mat_frame_data, | ||
struct frame_data * | p_frame_data | ||
) |
KAPI void material_system_release | ( | struct material_system_state * | state, |
material_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. |
void material_system_shutdown | ( | struct material_system_state * | state | ) |
Shuts down the material system.
state | The state block of memory. |
KAPI texture_filter material_texture_filter_get | ( | struct material_system_state * | state, |
khandle | material | ||
) |
KAPI void material_texture_filter_set | ( | struct material_system_state * | state, |
khandle | material, | ||
texture_filter | value | ||
) |
KAPI ktexture material_texture_get | ( | struct material_system_state * | state, |
khandle | material, | ||
material_texture_input | tex_input | ||
) |
KAPI texture_repeat material_texture_mode_get | ( | struct material_system_state * | state, |
khandle | material | ||
) |
KAPI void material_texture_mode_set | ( | struct material_system_state * | state, |
khandle | material, | ||
texture_repeat | value | ||
) |
KAPI void material_texture_set | ( | struct material_system_state * | state, |
khandle | material, | ||
material_texture_input | tex_input, | ||
ktexture | texture | ||
) |
KAPI b8 material_use_vertex_colour_as_base_colour_get | ( | struct material_system_state * | state, |
khandle | material | ||
) |