4

The space at which you transform your vertices is completely up to you, because it depends on what algorithms and kind of effects that you are trying to achieve. As of my personal experience, I usually shoot rays in world space because eventually we all need some sort of "world-space" acceleration data structure, such as a space-partition tree, that gathers ...


3

Because all matrices are column-major, the translation matrix $\mathbf{T}$ should be $$ \mathbf{T}=\begin{bmatrix} 1 & 0 & 0 & e_x \\ 0 & 1 & 0 & e_y \\ 0 & 0 & 1 & e_z \\ 0 & 0 & 0 & 1 \end{bmatrix} $$ I thought you mistakenly treat the eye as a row vector just because they were written as a single line in ...


3

It depends a little how you construct the matrix. I assume that you use the function perspective_matrix from your library, which actually works pretty much like good old gluPerspective). But what this actually does is nothing else than use the more general function frustum_matrix, which in turn creates a common arbitrary view frustum matrix, like good old ...


2

I would like to address an issue in your naming. This issue makes the question a bit odd, but not impossible, as I will try to show. There is an, often unspoken, implied relationship between the matrices. For a matrix to be meaningful there has to be a common ancestor of the matrix that all matrices relate to. See a transformation chain works like a disk ...


2

I'm assuming you mean $A$ is object$\rightarrow$world matrix and $B$ is your camera$\rightarrow$world matrix? If that's the case, to calculate object object$\rightarrow$camera matrix you calculate: $$C=B^{-1}*A$$ In general your math is correct, i.e. the order of matrix multiplication is reversed for the inverse calculation. It's just that normally these ...


2

Please read the references that are given to you: $$S = \dfrac{1}{\tan(\dfrac{fov}{2}*\dfrac{\pi}{180})}$$ $$ \left[\begin{array}{cccc} S && 0 && 0 && 0 \\ 0 && S && 0 && 0 \\ 0 && 0 && -\dfrac{f}{(f-n)} && -1\\ 0 && 0 && -\dfrac{f*n}{(f-n)} && 0\\ \end{array}\...


2

The math for the projection matrix is (with fov as $\alpha$): $q \leftarrow \frac{1}{tan(\frac{\alpha}{2})}$ $a \leftarrow \frac{q}{aspect}$ $b \leftarrow \frac{(far + near)}{(near - far)}$ $c \leftarrow \frac{(2 * far * near)}{(near - far)}$ Notice that there're some things you're doing that are differently, such as the order of your subtractions ...


2

Promoting my comment into an answer since it identified the problem... The issue is confusion between degrees and radians for the angle parameter. GLM, up to version 0.9.5, was very inconsistent in how it dealt with angles, accepting degrees for some functions and radians for others. This behaviour could be overridden with #define GLM_FORCE_RADIANS before ...


2

There is the whole derivation of it but I'll be discussing a brief overview. This is for the perspective projection where the line joining the eye and the center of the projection/image plane is perpendicular to it. Like here As we can easily see, by similar triangles $\triangle ABC$ and $\triangle AEF$ we have $Y_p / Y = D/-Z$ where $Y_p$ is the ...


2

That's how I used to initialize viewport (CD3DX12_VIEWPORT). But I didn't realize that there are two additional fields minDepth and maxDepth. Therefore, I have min/max depth set to 0.0 and objects rendered to depth buffer are always black: m_viewport.TopLeftY = 0.0f; m_viewport.TopLeftX = 0.0f; m_viewport.Width = static_cast<float>(m_windowSize.x); ...


2

You can construct a rotation matrix from an "axis", or 3 vectors. This is done by calculating 3 direction (normalized) vectors for the 3 axis of our new rotated coordinate system, they are forward, up and right vectors. In your case let's say we have 2 vectors called v1 and v2. we can produce a direction from them via (glsl psuedo code): vec3 ...


2

I belive what you are looking for is a scale Matrix, or actually it will end upp with as a shear matrix for you. Usually they look like this Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1 If you have no scaling, Sx, Sy, Sz represent the scaling in corresponding dimension. So put the to 1 for no scaling. But now you want to scale the height ...


2

"A not so simple approach". I may have messed a little bit too much with grouping the terms, do forgive my elementary math skills, it's a side effect of using tools like wolfram and mathematica too much. Without loss of generality we can assume that the near plane is given as $z=1$ (that is having normal $(0,0,1)$ and a point on it $(0,0,1)$) and the camera ...


1

I'm assuming the rotation matrix generated from the arcball is 2D, so I think there are a few clear top level steps. But I'm not sure about the details of some of them. First you'll need to extend the 2D rotation to 3D which should be easy. Next you'll need to rotate the rotation matrix itself so its axis aligns with your Forward vector. I'm not certain how ...


1

What you are asking about is 'mouse picking'. If a user clicks a pixel on the screen how can you get corresponding world space coordinates of an object being clicked on. Imagine a ray from that pixel, through the view volume all the way to the far plane. That ray is a set of all possible points the user is clicking on. So we want to perform ray/poly ...


1

It was getting a little big to fit in the comments so posting it as an answer instead. Might not be a solution to your problem but the concept is related. People usually forget that whenever you define a transformation matrix by placing respective basis vectors in respective columns, you are specifying that with respect to another basis usually the right-...


1

What you have there is the matrix that goes from eye space (camera space) to world space. You can see this by observing that, for instance, if you apply this matrix to the column vector $[1, 0, 0, 0]^T$, which is the right-vector in eye space, then it will return $[r_x, r_y, r_z, 0]^T$, the right-vector in world space. You want the matrix that transforms ...


1

Both the question and its answer is confusing. First of all the matrix you have is a column "Look at" view matrix rather than a model matrix. A correct column "Look At" model matrix would be $$\begin{bmatrix} side_x&side_y&side_z&0\\ up_x&up_y&up_z&0\\ Forward_x&Forward_y&Forward_z&0\\ eye_x&eye_y&eye_z&1 ...


1

You don't seem to get the concept right: A look-at camera matrix is created by defining two points, the "from" point (the dog eyes for example assuming you take the position of the eyes of the dog and average them to get the point in between) and a "to" point which is where the dog looks at. So if your dog is at (3,3,3) and that you want it to look at the ...


1

It's happening because they just happened to define the rotation matrix with counterclockwise rotation direction, which is the common convention for polar$\rightarrow$cartesian coordinate system transformation. If you google for the transformation, you'll see that the angle is universally shown to rotate to the counterclockwise direction like below


Only top voted, non community-wiki answers of a minimum length are eligible