<p>The MATLab data file has 3 arrays</p>

<ol>
<li>Input vector - aka, the light source (In Cartesian coordinates)</li>
<li>Output vector - aka, the eye (Also in Cartesian coordinates)</li>
<li>Spectral data (spectral data is discretized into 31 bins)</li>
</ol>

<p>So input[n], with output[n] results in spectral[n]</p>

<p>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:</p>

<p><a href="https://i.sstatic.net/yQqTA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yQqTA.png" alt="enter image description here"></a></p>

<p>The data is defined in the following range:</p>

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

<p>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]$$</p>

<p>Now, in order to use the data:</p>

<ol>
<li>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.</li>
<li>Apply the same transform to the output vector.</li>
<li>Using the transformed input and output vectors, look up the spectral response of the BRDF.

<ul>
<li>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.</li>
<li>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.</li>
</ul></li>
<li>Use the spectral values as the BRDF in the rendering equation</li>
</ol>

CC BY-SA 3.0
2016-01-20T07:23:31.213Z
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?
Fabrizio Duroni
CC BY-SA 3.0
2016-01-20T14:24:10.900Z
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
RichieSams
CC BY-SA 3.0
2016-01-20T06:15:29.523Z
2016-01-20T06:21:05.277Z
2016-01-20T06:21:05.277Z
RichieSams
<p>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:</p>

<p><a href="http://www.graphics.cornell.edu/online/measurements/reflectance/spraypaints/index.html" rel="nofollow">http://www.graphics.cornell.edu/online/measurements/reflectance/spraypaints/index.html</a></p>

<p>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).</p>

<ul>
<li>Which is the correct way to use this data?</li>
<li>Which sample technique must be used? </li>
<li><strong>Why phi_out has all negative value?</strong></li>
<li><strong>Can I calculate phi_out using the same approximation as the one I used in Oren Nayar, so ||View - Normal * (View.dot(normal)||</strong></li>
</ul>

CC BY-SA 3.0
2016-01-19T23:32:20.063Z
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?
RichieSams
CC BY-SA 3.0
2016-01-19T23:55:21.643Z
Hi @RichieSams i update my question with more specific problems. Ok for the linear interpolation (I want to keep thing simple at the moment :))
Fabrizio Duroni
<raytracing><brdf>
Ray tracing - BRDF using Cornell measured spectral data
Fabrizio Duroni
# Ray tracing - BRDF using Cornell measured spectral data

(Asked by: username_0 on 2016-01-19)

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:

<http://www.graphics.cornell.edu/online/measurements/reflectance/spraypaints/index.html>

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)||**

**Tags:** raytracing, brdf

> **Comments:**
> **username_1**: 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?  
> **username_0**: Hi @username_1 i update my question with more specific problems. Ok for the linear interpolation (I want to keep thing simple at the moment :))  

---

## 1 answers

### Answer by username_1 on 2016-01-20. Score: 4

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](https://i.sstatic.net/yQqTA.png)](https://i.sstatic.net/yQqTA.png)

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

> **Comments:**
> **username_0**: Thank you @username_1. 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?  
> **username_1**: 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  

---

