Skip to content

Uniforms per Instance

Each instance can have its own shader uniform values, stored in a texture and automatically injected into the material shader.

iMesh.initUniformsPerInstance({
vertex: { wave: 'float' },
fragment: { metalness: 'float', roughness: 'float', emissive: 'vec3' }
});

Supported types are float, vec2, vec3, vec4, mat3 and mat4.

Set and Get Values

iMesh.setUniformAt(index, 'metalness', 0.5);
// if an array of instances has been created
iMesh.instances[index].setUniform('emissive', new Color('white'));

Values can be a number or a three.js object (Vector2, Vector3, Vector4, Color, Matrix3, Matrix4).