Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.8 - Model Matrix #64

Open
radhikamattoo opened this issue Nov 11, 2017 · 3 comments
Open

1.8 - Model Matrix #64

radhikamattoo opened this issue Nov 11, 2017 · 3 comments

Comments

@radhikamattoo
Copy link

radhikamattoo commented Nov 11, 2017

I'm confused how to factor in the barycenter subtraction/addition we need to perform for scaling/rotation into the model matrix.

I am able to upload the model matrix as a uniform, but combining 1. subtraction of the barycenter 2. multiplying for scale and 3. addition of the barycenter into the model matrix gives the scaling factor correctly in the first 2 columns, but the the last column for adding/subtracting the barycenter is just 0.

How are we supposed to force the above order (1, 2, 3) in a single model matrix?

@danielepanozzo
Copy link
Owner

Hi,

as long as you represent the transformation using affine matrices (i.e. 4x4 matrices if your points have 3 coordinates), you can simply combine them by multiplying them together as we did in the class. The order matters, and you need to figure out which one is correct for your specific problem.

Hope this helps!

@radhikamattoo
Copy link
Author

radhikamattoo commented Nov 11, 2017

Hi Professor,
I was thinking of uploading multiple uniforms (one for translation, one for scaling, and one for rotation) and then multiplying them together along with the position in the vertex shader. Would this be acceptable? In the instructions it mentions just a single model matrix.
Thank you!!

@danielepanozzo
Copy link
Owner

It is acceptable, but it is unnecessary and harmful for performances. You should try to minimize the amount of things that you send to the shader, and I don't see any reason (for this specific case) to do the product of the three matrices inside the shader instead that on the cpu side before uploading the uniform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants