سؤال

I have a couple of questions about modern opengl:

(i) A Model matrix is described as a "contains every translations, rotations or scaling, applied to an object"(1)

(ii) So that must mean for every VAO(contains a scene object, such as a chair) there must be a vertex attribute, a 4x4 Model matrix, that contains the translation, rotation and scaling of that object in order for the vertex shader to transform that each vertex into world space, right?

Therefore, would i have 32 Model matrices if i had 32 scene objects(1 Model matrix per scene object)?

(iii) Then could i deal with the View and Projection matrices as a couple of uniforms to the shader?

(iv) If a program has more than 1 scene object, such as a table and chair with different translation, rotation and scaling, is it possible to have 1 Model matrix that accommodates each scene object's different translation, rotation and scaling?

هل كانت مفيدة؟

المحلول

(i) A Model matrix is described as a "contains every translations, rotations or scaling, applied to an object"(1)

No. A matrix is just a matrix. Only in a certain context a matrix gains additional meaning.

(ii) So that must mean for every VAO(contains a scene object, such as a chair) there must be a vertex attribute, a 4x4 Model matrix, that contains the translation, rotation and scaling of that object in order for the vertex shader to transform that each vertex into world space, right?

No.

VAOs are not models. VAOs are just collections of references to memory hunks. There can be any kind of data contained in a VAO. And if the VAO contains geometry data there can be multiple, independent models in a single VAO.

Therefore, would i have 32 Model matrices if i had 32 scene objects(1 Model matrix per scene object)?

Not necessarily. You could as well have 16 matrices, where 2 objects each share their modelview transformation.

(iv) If a program has more than 1 scene object, such as a table and chair with different translation, rotation and scaling, is it possible to have 1 Model matrix that accommodates each scene object's different translation, rotation and scaling?

Well, yes, but don't overthink the problem. There's no strict tie between objects and transformation matrices.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top