I wrote a ray tracer that implements various BRDF models (Oren Nayar, Lamber, Torrance Sparrow and so on). Now I'm trying to implement a BRDF from measured data. I choose the Cornell database data available here:


I want to use them because there's a representation of the data as spectrum with 31 sample (my ray tracer use spectral data for light calculation and then convert them to CIE XYZ and then RGB values for the final image rendering).

  • Which is the correct way to use this data?
  • Which sample technique must be used?
  • Why phi_out has all negative value?
  • Can I calculate phi_out using the same approximation as the one I used in Oren Nayar, so ||View - Normal * (View.dot(normal)||
  • 2
    $\begingroup$ Could you elaborate on what you mean by sampling? The data is just a LUT. The simple way to use it would be to look up the closests input / output vectors and LERP the spectral data between them. Or do you mean how to importance sample? $\endgroup$
    – RichieSams
    Jan 19, 2016 at 23:32
  • $\begingroup$ Hi @RichieSams i update my question with more specific problems. Ok for the linear interpolation (I want to keep thing simple at the moment :)) $\endgroup$ Jan 19, 2016 at 23:55

1 Answer 1


The MATLab data file has 3 arrays

  1. Input vector - aka, the light source (In Cartesian coordinates)
  2. Output vector - aka, the eye (Also in Cartesian coordinates)
  3. Spectral data (spectral data is discretized into 31 bins)

So input[n], with output[n] results in spectral[n]

The ASTM file is a flattened version of the MATLab data file, with one major difference: the input and output vectors are in spherical coordinates, specifically the traditional physics notation:

enter image description here

The data is defined in the following range:

For input vector, $\theta$ (theta) varies from $0$ to $\frac{\pi}{2}$, and $\phi$ (phi) is always a constant $0$.

The output vectors are uniformally distributed across the hemisphere. Since $\phi$ is periodic on $2\pi$, mathematically you can define the bounds of $\phi$ in an infinite number of ways. In this data set they chose: $$\phi = [-\pi, \pi]$$ but it would be perfectly fine to choose $$\phi = [0, 2\pi]$$

Now, in order to use the data:

  1. Since the input vectors only vary over a quarter circle ($\theta = [0, \frac{\pi}{2}]$ and $\phi = 0$), not the whole hemisphere, you will need to find the matrix transform that transforms your input vector to the quarter circle.
  2. Apply the same transform to the output vector.
  3. Using the transformed input and output vectors, look up the spectral response of the BRDF.
    • I'm not sure of the best way to do this. I defer to others' opinions. I'm sure there is some kind of data structure / algorithm to do the search.
    • The naive way would be to do a O(n) search of all the input and output directions to find the two or three that are closest, then LERP between them.
  4. Use the spectral values as the BRDF in the rendering equation
  • $\begingroup$ Thank you @RichieSams. So what about that transformation matrix? Is it some kind of change of coordinate matrix, for example like the one used for transform input data to a camera coordiante system? $\endgroup$ Jan 20, 2016 at 7:23
  • 1
    $\begingroup$ Exactly. It's a change of coordinate matrix. The data is in world coordinate space. And specifically, the input vector is a small portion of the space. So transform to world, then rotate to the input vector domain $\endgroup$
    – RichieSams
    Jan 20, 2016 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.