Skip to content

Hardware instancing #6739

Closed Answered by bejado
gibssa asked this question in Q&A
Apr 16, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

material.worldPosition sets the position of a vertex. By default (in the OBJECT vertex domain), it is computed like so:

mat4 transform = getWorldFromModelMatrix();
vec3 position = getPosition().xyz;
material.worldPosition = mulMat4x4Float3(transform, position);

So if you want to pass a unique transform per instance, you somehow need to customize transform depending on the instance. How you do this depends on what you're trying to achieve. If you have some matrices on the CPU you'd like to use, you could pass them as a float3×3 parameter array and use getInstanceIndex() to index into them.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@gibssa
Comment options

@gibssa
Comment options

Answer selected by gibssa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants