33 votes
Accepted

Why is the transposed inverse of the model view matrix used to transform the normal vectors?

Here's a simple proof that the inverse transpose is required. Suppose we have a plane, defined by a plane equation $n \cdot x + d = 0$, where $n$ is the normal. Now I want to transform this plane by ...
Nathan Reed's user avatar
  • 24.7k
26 votes
Accepted

What are Affine Transformations?

An Affine Transform is a Linear Transform + a Translation Vector. $$ \begin{bmatrix}x'& y'\end{bmatrix} = \begin{bmatrix}x& y\end{bmatrix} \cdot \begin{bmatrix}a& b \\ c&d\end{bmatrix}...
luser droog's user avatar
  • 1,343
19 votes
Accepted

Cause of shadow acne

Image 1: A bad case of shadow acne. (Synthetic and a bit exaggerated) Shadow acne is caused by the discrete nature of the shadow map. A shadow map is composed of samples, a surface is continuous. ...
joojaa's user avatar
  • 8,377
17 votes
Accepted

What is the correct order of transformations scale, rotate and translate and why?

Usually you scale first, then rotate and finally translate. The reason is because usually you want the scaling to happen along the axis of the object and rotation about the center of the object. In ...
JarkkoL's user avatar
  • 3,596
15 votes

Why are Homogeneous Coordinates used in Computer Graphics?

They simplify and unify the mathematics used in graphics: They allow you to represent translations with matrices. They allow you to represent the division by depth in perspective projections. The ...
lhf's user avatar
  • 724
11 votes

Why is the transposed inverse of the model view matrix used to transform the normal vectors?

This is simply because normals are not really vectors! They are created by cross products, which results in bivectors, not vectors. Algebra works much different for these coordinates, and geometric ...
ap_'s user avatar
  • 2,194
11 votes
Accepted

Computing a rotation: complex numbers vs rotation matrix

Both methods end up doing the same calculations when you break it down. Rotating a vector $u$ with a matrix: $$\begin{bmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{bmatrix} \...
Nathan Reed's user avatar
  • 24.7k
11 votes
Accepted

Is it possible to turn a 3d rotation matrix (4x4) into its component parts (rotation, scale, etc.)?

You can decompose the matrix $\mathbf{M} = \mathbf{TRS}$ into basic transformations: translation, scaling, and rotation. Given this matrix: $$\mathbf{M} = \begin{bmatrix} a_{00} & a_{01} & a_{...
user5488's user avatar
  • 156
9 votes

How to combine rotation in 2 axis into one matrix

(This answer is essentially the same as Stefan's but I wanted to add some detail about row and column vectors, and how to determine which you are using.) Yes, this is possible, but the details depend ...
Martin Ender's user avatar
  • 2,720
9 votes

When should quaternions be used to represent rotation and scaling in 3D?

I want to start with misconceptions: Modern GPUs (NVIDIA for quite a while, and AMD since Southern Islands) do not meaningfully support vector/matrix operations natively in hardware. They are vector ...
John Calsbeek's user avatar
9 votes
Accepted

When is it better to upload partial model matrices to the vertex shader?

Doing math with uniforms is a shader won't usually get you any performance over doing it on the CPU. A CPU isn't slower than a GPU at doing matrix math, it just isn't structured so as to do large ...
John Calsbeek's user avatar
9 votes

Cause of shadow acne

As an addition to the answer of joojaa: Using a bias to offset the shadow function does indeed solve the problem with shadow acne, but it can introduce an additional problem: Peter Panning As you see ...
Dragonseel's user avatar
  • 1,800
8 votes
Accepted

Image rotation using FFT

Fourier transforms wouldn't help you with a rotation. You'd just end up having to rotate the matrix of Fourier coefficients, instead of rotating the original image. Consider for example an image made ...
Nathan Reed's user avatar
  • 24.7k
7 votes
Accepted

Ray Transformation to Object Space for Motion Blur

Lerping the ray positions/directions between keyframes should be equivalent to lerping the inverse matrices between keyframes and transforming by the lerped matrix. Trouble is, if the keyframes have ...
Nathan Reed's user avatar
  • 24.7k
7 votes

Why are Homogeneous Coordinates used in Computer Graphics?

It's in the name: Homogeneous coordinates are well ... homogeneous. Being homogeneous means a uniform representation of rotation, translation, scaling and other transformations. A uniform ...
NoAnswer's user avatar
7 votes

Why are Homogeneous Coordinates used in Computer Graphics?

Imagine you want to represent transformations using matrices. Points could be stored as $$\begin{bmatrix}x\\y\end{bmatrix}$$ and you could represent a rotation as $$\begin{bmatrix}u\\v\end{bmatrix}=\...
Chuck's user avatar
  • 296
7 votes
Accepted

Is there a way to script image creation?

ImageMagick is a set of command-line tools that can do the sort of things you describe. For example, this command line will overlay picture B with a centered copy of picture A, resized to 100 pixels ...
Nathan Reed's user avatar
  • 24.7k
7 votes
Accepted

How to invert an affine matrix with small values?

I found a solution to my specific problem. Instead of computing the determinant and hitting the precision wall, I use the Gauss-Jordan method step by step. In my specific case of affine ...
solendil's user avatar
  • 251
7 votes
Accepted

Moving each point of a surface in direction of corresponding normal

No this cannot be modelled by (non-uniform) scaling. It's fairly easy to construct a counterexample: The issue is that the amount a section of the curve/surface grows depends on its curvature, not ...
Martin Ender's user avatar
  • 2,720
7 votes

Is there a objective reason for matrix naming conventions?

I think the naming order is intuitive because it is in reading order (left to right), e.g., worldViewProjection means that your point/direction is first multiplied by the world matrix, then the view ...
vgs's user avatar
  • 311
7 votes

Can a scene graph be stored in the GPU?

Short answer: Yes, It can be done. But no one does so. Long answer: Scene graphs can be stored and processed on a GPU using OpenCL/WebCL. But it is not practical to do so. Updating scene graphs (a ...
Mary Chang's user avatar
7 votes
Accepted

Why do I need to inverse the orientation matrix of a camera to be able to translate it in the direction it is facing?

People always forget that there is no "camera" in OpenGL. In order to simulate a camera you have to move the whole world inversely. So if you want ur camera looking 30 degrees downward, you move the ...
gallickgunner's user avatar
6 votes

When should quaternions be used to represent rotation and scaling in 3D?

(A lot of information here I shamelessly borrowed from joojaa's and ratchet freak's answers, with some notes of my own.) Matrix Advantages Non uniform scaling and rotation, skewing, projection ...
Jorge Rodriguez's user avatar
6 votes
Accepted

Why is the color in the cube being weirdly swapped?

It is likely that your specific problem arises from a singularity in atan when m_position.z goes to 0. Rather than try to debug ...
yuriks's user avatar
  • 1,130
6 votes

How to combine rotation in 2 axis into one matrix

Yes, just multiply them in reverse order: Matrix myrotation = Matrix.CreateRotationX(xrot) * Matrix.CreateRotationZ(zrot); EDIT. My answer only applies if you ...
Stefan Agartsson's user avatar
6 votes
Accepted

Graphics Pipeline: Viewspace & Back face culling incorrectly

I (believe) I've solved this (even if it has taken 2 days). My problem was essentially I wanted to take the dot product of the face normal, and line-of-sight vector like below And determine the angle ...
davidhood2's user avatar
6 votes

Rotate line around center

Trick is, to move the entire object so that the point about which you want to rotate is at the center. Then rotate and after that counter move it so that the point is were it was. In fact this is not ...
joojaa's user avatar
  • 8,377
6 votes
Accepted

Animating a smooth linear transformation

As a general rule, you cannot interpolate transformation matrices. In stead, you decompose them into their individual values, then interpolate those and recompose. The Möbius transformation as ...
Paul-Jan's user avatar
  • 266
6 votes
Accepted

Zoom in orthographic vs perspective projection

Perspective projection changes the size of an object as it's distance changes, while orthographic projection does not. That is part of the definition of those projection types. To simplify things a ...
Alan Wolfe's user avatar
  • 7,721
6 votes
Accepted

Minimum requirements to uniquely represent a 3D object in space

A rigid body has 6 degrees of freedom, in 3D- space. So that means you need 6 values to represent the object. The common way to do this is to store a position vector for position and 3 rotations. But ...
joojaa's user avatar
  • 8,377

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