Reputation: 107
Im seeing that i must send 1 MVP matrix to the vert shader, but don't i need to send multiple model matrices if i have more then 1 model in my scene?
For example, if i have 2 teapots, each with a different model matrix that has been translated, rotated, and scaled differently than the other teapot. If i can can only send 1 of the teapots's model matrix, a part of the M in the MVP matrix sent to the shader, then as my VAO vertex data is fed into the vert shader, both teapots will be transformed according to the 1 model matrix that i choose to send to the shader.
Upvotes: 4
Views: 1241
Reputation: 72479
Suppose you want to render two teapots with different transformations each. There are two choices:
Pass the transformation through a uniform. You will have to set the uniform, render one teapot, update the uniform and render the teapot again.
Pass the transformation through vertex attributes. You make an instanced vertex attribute (two vec4
will do if you encode it with offset + quaternion) and render two teapots with an instanced draw command.
The first is the 'simple' method that is usually taught it tutorial. However, when you render multiple instances of the same object then the second method might be beneficial.
So as you see you can pass more than one model matrix to the GPU simultaneously.
Upvotes: 2