- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4
BxDF and camera coordinate systems
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.)
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:
(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:

Where t is the translation of the camera.
Here is a numerical representation of our matrix:

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.