Tag Info

How does a 4x4 matrix represent an object in space and matrix lore?

How is Matrix Multiplication a Transformation? A matrix is just a big grid of numbers with rules that define how we can multiply it with other grids or lists of numbers. In games, we usually want to ...
• 135k

How and when do the model to world, world to view, et cetera multiplications happen?

Think about it logically: What is your goal when you render something? To display it on the screen! What are the constraints? The model must be visible to the camera (i.e. in the view frustum, not ...
• 501
Accepted

lookAt with orthographic camera (gl-matrix)

When I use the identity view matrix, I can see my model, but when I use LookAt, it is not visible. How can I see my model using ...
• 9,029

Confused About My Code Suggesting The Normal Matrix Is Equivalent To The ModelView Matrix

When a matrix is orthogonal, inverse and transpose are equivalent making an inverse transpose equal to the original matrix. So if your model view matrix is orthogonal, the normal matrix will be equal ...
Accepted

How to mirror/reflect/flip a 4D transformation matrix

To get a transformation matrix equivalent to the one you have, but reflected across a major axis you can compose it (multiply it by) a reflection matrix. That is, if you have your input matrix M and ...
• 27.3k
Accepted

Finding islands from array

This is a standard computer science problem called connected component search. You can solve it in time linear in the number of cells using iterated depth-first / breadth-first search or a flood fill ...
• 135k

How do you make a camera look at a box and ensure all of it is visible?

Take every point (vertex), project them into screen space (basically multiply them with the projection * view * model matrix). After you got this, take every point ...
• 14.9k
Accepted

How to convert a 4x4 matrix transformation to another coordinate system?

This is as easy as writing your old coordinates in terms of the new ones. We want +x to map to +x (1, 0, 0) We want +y to map to +z (0, 0, 1) We want +z to map to -y (0, -1, 0) We want the fourth, ...
• 135k
Accepted

How to convert -1 to 1 coordinate back to screen coordinates?

For this problem specifically: screenX = ((glX + 1) / 2.0) * maxScreenX; screenY = ((glY + 1) / 2.0) * maxScreenY; In general, the solution for going from ...
• 12.4k
Accepted

How much matrices should I use for OpenGL transformation?

Your object is transformed in multiple steps, and for each step, you usually use a matrix. You can rotate, scale and translate every model. This can be done with three separate matrices, but usually ...
• 361

From 3d rotation, snap to nearest 90 directions

For anyone in the future looking for a solution to this using Unity/C#, here is an implementation I made based on Steve's answer: ...

How do I create a view matrix that does not contain the camera translation?

In fact you don't need to create a second matrix separately. To remove any translation you just need to cast the matrix to mat3 and back to ...
• 2,035
Accepted

Issues with OpenGL rotation matricies and shaders

You're off by 1 in your matrix initialization. The matrix rows are 4 entries wide (4x4 matrix) but you're initializing them like they're 3 entries wide. ...
Accepted

multiply matrix4x4 with vec4

Matrix-vector multiplication works the same as matrix-matrix multiplication, because a 4d vector is basically matrix with one of the dimensions equal to 1. If we have a vector ...
• 14.9k

How much matrices should I use for OpenGL transformation?

In professional games every object in the world will have its own world matrix. This is usually stored in some structure that represents your entity in the world, or some component hanging off that ...
Accepted

Normal Matrix in plain English

You need to use a different matrix to transform your normal vectors when your model's transformation might include non-uniform scale. When we stretch a shape along, say, just the y axis, the y ...
• 135k

How does glm::lookAt produce a View Matrix?

Alright so upon looking into it further, here's how glm::lookAt produces a View Matrix: Make a row-major ordered 4x4 Translation Matrix by negating the camera position, c: ...
• 61
Accepted

Difference between World matrix and Model matrix?

The names "world matrix" and "model matrix" are just terminology, and are not 100% standardised, so depending which source you read you may see them being used to refer to a number ...
• 20.2k
Accepted

How do I create a localtoworldmatrix and worldtolocalmatrix in Godot?

In Godot a Transform3D has no concept of local or world. They are transformations between spaces, and what those spaces are depend on how you use them. For a ...
• 27.3k
Accepted

How would you design a transformation matrix to project absolute coordinates to any orthographic projection desired?

I'm going to make some assumptions... Your 3D world coordinate system is left-handed, with the y axis pointing up in the world. You want to convert to camera space, where y is up on the screen, x is ...
• 135k
Accepted

Yes, there is no way to pass a float4x4 to an input description. By doing that you'd be passing a matrix for every vertex to your vertex shader. This is bad practice unless you need to bind a ...
• 1,383
Accepted

Get the difference between 2 matrices

Your problem is that you're trying to compare floating-point numbers for equality. The matrix inversion and multiplication, however, will inevitable introduce slight rounding errors that will make ...
• 8,347

Why does GLM only have a translate function that returns a 4x4 matrix, and not a 3x3 matrix?

You still need 4x4 for the projection matrix, even in 2D. Typically you will use a combined MVP matrix in your shaders rather than separate matrices, so the calculations are easier (and faster - 4x4 ...
• 20.2k

How and when do the model to world, world to view, et cetera multiplications happen?

Please allow me to elaborate what the responsibility of the GPU should be in the most common scenarios as well as the responsibilities of the CPU, game-engine, and OpenGL. Basics to the OpenGL ...
Accepted

Why do these DirectXMath functions seem like they return column-major matrics?

You posted a column-major version of the translation matrix for (1,1,-1): 1.0 0.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 0.0 1.0 -1.0 0.0 0.0 0.0 1.0 ...
• 3,922
Accepted

3d isometric projection matrix?

You should try having a separate camera and projection matrix, since isometric projection is just ortographic with a very specific camera placement. If you are using a modern matrix library (you ...
• 14.9k
Accepted

Should 3D transformations be represented by a 4x4 matrix or a 3x4 matrix?

Since 3D transformations are represented by 4x4 homogeneous matrices Correction: Might be represented by 4x4 matrices ;) Now I can see how this would be a great optimization at first as it ...
• 589