natiny_material_set_constant

C
void natiny_material_set_constant(NatinyMaterial material, const char* name,
                                  float x, float y, float z, float w);

Sets a scalar or vector constant by its shader member name.

Parameters

Name Type Description
material NatinyMaterial Material handle
name const char* Member name inside one of the shader's uniform blocks
x, y, z, w float Components; anything past the member's size is dropped

Example

C
natiny_material_set_constant(material, "tint", 1.0f, 0.5f, 0.5f, 1.0f);

Notes

  • Only as many components as the member holds are written. The same name is updated in every block and shader stage where it appears.
  • Engine-owned constants are overwritten on every draw. Change their ownership with natiny_material_set_vertex_constant before setting them as user values.
  • For a mat4 use natiny_material_set_matrix.
  • An unknown name is reported on stderr and ignored.