+1 vote

Would like to understand how to apply transformations, like mentioned here in docs: https://docs.godotengine.org/en/stable/tutorials/math/matrices_and_transforms.html
but with Godot shaders.

For example, after making an identity matrix, i.e. mat4(1), and multiplying it by 2 to duplicate the size, how can I apply it for example on UV, i.e. vec2, coordinates?

in Engine by (13 points)

1 Answer

0 votes

Nothing too complicated, you just use the * multiplication operator. Note though that it only makes sense to multiply a mat4 by another mat4 (4x4), vec4 (4x1), or other 4x? matrix.

If you're just aiming for 2D scaling and rotation, you probably want to start with a mat2. mat2 * vec2 = vec2

by (394 points)

Just remembered about http://matrixmultiplication.xyz/ - this is a good way to visualise what's actually going on during one of these operations.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.