Skip to content

BxDF and camera coordinate systems

n8xm edited this page Feb 15, 2018 · 10 revisions

PBRT considers +z ( a.k.a. the unit vector k ) to be both the normal direction and the "up" direction when defining a spherical coordinate system for BRDFs. (You can think of the BRDF's coordinate system as being the same as that of the tangent space that exists at the relevant point on the geometry being rendered.)

⚠️ This is a left-handed coordinate system ⚠️, while OpenGL uses a right-handed coordinate system for world space and model space.

By default, we would like our camera to view the BRDF from the side. See the following diagram, where the blue axes represent camera space:

images/camera_coords_vs_pbrt.PNG

(The above image comes from the PBRT textbook, 3rd edition, chapter 5.5.2, figure 5.14.)

In the above coordinate system, the following are true:

x = sin(θ)cos(ϕ)
y = sin(θ)sin(ϕ)
z = cos(θ)

Furthermore, observe:

  • i in world space is i in camera space.
  • j in world space is k in camera space.
  • k in world space is j in camera space.

Therefore our starting view matrix (a.k.a. world-to-camera matrix) will look like this:

images/default_view_mat.png

Where t is the translation of the camera.

Here is a numerical representation of our matrix:

images/default_view_mat_numeric.png

Using the glMatrix library, this is represented as the following in code:

[1,    0,    0,    0,
 0,    0,    1,    0,
 0,    1,    0,    0,
 -t_x, -t_y, -t_z, 1]

Note that the matrix is "transposed" due to the column-major representation of matrices in WebGL.

Clone this wiki locally