## Dispersion

Practical and theoretical implementation discussion.
rheniser
Posts: 2
Joined: Fri Aug 21, 2015 6:59 am

### Dispersion

I am trying to approximate dispersion by stochastically sampling refraction rays derived from randomly sampled wavelengths in the visible spectrum. My resulting renders are much darker than I would expect, which I suspect is coming from my uncertainty of color theory and models in this case.

Following the common approach, like presented in Raytracing of Dispersion Effect In Transparent Materials (by Wilkie, Tobler, and Purgathofer), I randomly sample a wavelength (in the visible spectrum of 360-780 nm) and convert it to the CIE XYZ 1931 Standard Observer values (https://www.rit.edu/cos/colorscience/rc_useful_data.php).

Next, I convert the CIE XYZ 1931 values to Linear sRGB (D65) by multiplying by the color transform matrix (https://en.wikipedia.org/wiki/SRGB). This transformation can result in Linear sRGB values that are out of the [0.0, 1.0] range. For example:

Code: Select all

|  3.2406 −1.5372 −0.4986 |   | 0.2511 |   | −0.06179508  |
| −0.9689  1.8758  0.0415 | x | 0.0739 | = | −0.04125302  |
|  0.0557 −0.204   1.057  |   | 1.5281 |   |  1.61411237  |

According to most sources, including https://en.wikipedia.org/wiki/SRGB, the linear RGB values are usually clipped to [0.0, 1.0], with display white represented as (1.0, 1.0, 1.0).

If I want to render dispersion, clipping here I think would be problematic. It appears to me that I would be clipping out samples, resulting in darker renders due to clipped out energy.

One possible solution that comes to mind is restricting my sampling to wavelengths that result in [0.0, 1.0] RGB value without clipping. I will try this next.

If clipping is the usual approach, are there other common ones, perhaps normalizing, that would work better here? Normalizing I suspect would result in an undesirable color shift.

friedlinguini
Posts: 89
Joined: Thu Apr 11, 2013 5:15 pm

### Re: Dispersion

rheniser wrote:According to most sources, including https://en.wikipedia.org/wiki/SRGB, the linear RGB values are usually clipped to [0.0, 1.0], with display white represented as (1.0, 1.0, 1.0).
It's not entirely clear, but it sounds like you're talking about clamping individual samples. Don't do that. Just average the unclamped sample values and then clamp the average. Yes, there's still potential energy loss and color shifting, but that's the usual result of tone mapping to a low dynamic range display.

rheniser
Posts: 2
Joined: Fri Aug 21, 2015 6:59 am

### Re: Dispersion

Yes, that is where I went wrong. When I normalize the linear sRGB values and clamp at the end, I get a much better result: Normalized and clamped
normalized.png (200.12 KiB) Viewed 5614 times
Here are the averages for the table data (https://www.rit.edu/cos/colorscience/rc_useful_data.php) and the single lobe approximation (http://jcgt.org/published/0002/02/01/) for the wavelength to linear sRGB conversion:

Average Linear sRGB D65 (360-780 nm at 5 nm steps) = {0.30276, 0.23830, 0.22843}, Max = {2.51679, 1.50899, 1.89752}, Min = {-0.92539, -0.22180, -0.16958}

Average Linear sRGB D65 (360-780 nm at 0.5 nm steps) = {0.30884, 0.23873, 0.22871}, Max = {2.49697, 1.51144, 1.96021}, Min = {-0.80496, -0.25638, -0.18061}
Average Linear sRGB D50 (360-780 nm at 0.5 nm steps) = {0.26359, 0.24440, 0.31418}, Max = {2.34045, 1.54728, 2.60592}, Min = {-0.87620, -0.27376, -0.19881}

Thank you,
Ryan