27 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 ...
user avatar
  • 23.6k
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}...
user avatar
  • 1,288
17 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. ...
user avatar
  • 8,169
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 ...
user avatar
  • 714
15 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 ...
user avatar
  • 3,556
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_{...
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 ...
user avatar
  • 2,580
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 ...
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 ...
user avatar
9 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} \...
user avatar
  • 23.6k
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 ...
user avatar
  • 23.6k
8 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 ...
user avatar
  • 1,750
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 ...
user avatar
  • 23.6k
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 ...
user avatar
7 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 ...
user avatar
  • 1,974
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 ...
user avatar
  • 23.6k
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 ...
user avatar
  • 241
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 ...
user avatar
  • 2,580
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 ...
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 ...
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 ...
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 ...
user avatar
  • 1,100
6 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}=\...
user avatar
  • 276
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 ...
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 ...
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 ...
user avatar
  • 8,169
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 ...
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 ...
user avatar
  • 7,341
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 ...
user avatar
  • 8,169
6 votes

Gimbal lock confusion

Gimbal lock is your item 1. It is the situation where we have rotated our 2nd axis (in the order of application of the three axes) by ±90 degrees, which aligns the 1st axis and the 3rd axis together, ...
user avatar
  • 23.6k

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