cf_material_set_uniform_fs¶
Category: graphics
GitHub: cute_graphics.h
Sets up a uniform value, used for inputs to fragment shaders.
void cf_material_set_uniform_fs(CF_Material material, const char* name, void* data, CF_UniformType type, int array_length);
Parameters | Description |
---|---|
material | The material. |
name | The name of the uniform as it appears in the shader. |
data | The value of the uniform. |
type | The type of the uniform. See CF_UniformType. |
array_length | The number of elements in the uniform array. Usually this is just 1 , as in, not an array but just one variable. |
Remarks¶
Uniforms set here do not need to exist in the shader. It's completely acceptable (and encouraged) to setup many uniforms in a material.
Once the material is applied via cf_apply_shader, all shader input uniforms (e.g. uniform vec4 u_my_color
) are dynamically matched up
with uniform values stored in the CF_Material. Any uniforms in the material that don't match up will simply be ignored, and cleared to 0
in the shader.
CF_Material's design supports using one material with various shaders, or using various materials with one shader. Since uniforms are grouped up into uniform blocks the performance overhead is usually quite minimal for setting a variety of uniform and shader combinations.
Related Pages¶
CF_UniformType
CF_Material
cf_make_material
cf_destroy_material
cf_material_set_render_state
cf_material_set_texture_vs
cf_material_set_texture_fs
cf_material_set_uniform_vs