Instancing
One shape drawn many times in one call, each copy with its own attributes.
Vbo.upload_attribute
Vbo.upload_attribute(name, data, divisor=0, usage=None)Gives each vertex, or each instance, a named value for raw shaders.
A raw shader (Shader.load) that declares in float age; reads the Vbo’s "age". Kiln binds attributes by name, and gives each named input a location from 4 up. Setting a name again replaces it (with another size or type if you like); a rewrite of the same size is cheap even after a draw in the same frame (see the class docstring).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| name | str | The GLSL input’s name (not position, color, normal or texcoord, which are the built-in data). |
required |
| data | ArrayLike | An (n,) or (n, k) array, k from 1 to 4: floats for float/vecK inputs, integers for int/ivecK (signed) or uint/uvecK (unsigned). n is the vertex count, or the instance count with divisor=1. |
required |
| divisor | int | 0 for one value per vertex, 1 for one per instance (draw(instances=...)); other divisors aren’t supported. |
0 |
| usage | BufferUsage | BufferUsageValue | None | A BufferUsage hint; the current one if omitted. |
None |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | A bad name, shape or divisor, or integers out of 32-bit range. | |
| TypeError | The data isn’t numbers. | |
| RuntimeError | No App is running. |
Vbo.instance_count
Vbo.instance_count
Returns how many instances a draw can have.
Returns
| Name | Type | Description |
|---|---|---|
| int | The smallest per-instance attribute’s count, or 0 without any. |