## Colorspaces questions, and light shape questions

Practical and theoretical implementation discussion.
Neuromodulator
Posts: 1
Joined: Tue Jun 16, 2015 8:47 pm

### Colorspaces questions, and light shape questions

Hello everyone,

I discovered this forum today, no clue what ompf means but from the photo and the content it looked it is what I was looking for....

To learn C++11, I decided to program a path tracer, thought it would be a good non trivial project were I could use lots of the new features C++ features.

I decided that I would go for a non banded full spectrum tracer, the conversion from spectrum to XYZ seems to be quite trivial, although there are a couple of different functions to do the conversion, seems they will mostly look too similar to even bother with them. Then when it comes to convert from XYZ into RGB, I'm not quite sure what the best way to go there is. Some colorspaces like sRGB have a linear part, also different color spaces use different illuminants, like D50 or D65, not sure if those concepts make any sense here. Any help would be appreciated...

My main goal in my tracer is to make it as physically based as possible, and as generic as possible, for the same reason I dont separate objects from light sources. One issue I'm currently having is how to pick random points (light rays) of arbitrary matrix transformed shapes. As an example, to picking a random point from the surface of a sphere is quite trivial, but not that much when I transform the surface.

junketsu
Posts: 2
Joined: Thu May 15, 2014 5:43 am

### Re: Colorspaces questions, and light shape questions

Hi.

Have you read Colour Rendering of Spectra [1]?

The problem of different colorspaces is solved by using corresponding matrices for XYZ->RGB transform, but I think the CIE Rec 709 matrix is enough, especially if sRGB is a primary colorspace of your renderer output. Furthermore it will be problematic to use more optional colorspaces in consideration of the following steps.
The matrix multiplication produces weird RGB tuples. It is necessary to fit its values to (0,1) range. Walker proposes the trivial solution for this [1].
The final spectrum probably will be non-ligned, its average color will be not pure 50% grey, but with some considerable tint. I've resolved this by adjusting borders of the spectrum, until it returned grey.
Actually, this tint seems to be a problem of a Spectrum Power Distribution, which is a function of sensor (I didn't dive into).

I'm not sure that my solution is correct, but I have satisfactory results (at least it's better than HSV trick). Here is my old ipynb http://nbviewer.ipython.org/gist/ground ... 0e1f4f2875 . See fourth section.

P.S. I used [2] for wavelength -> XYZ transform.

[1] https://www.fourmilab.ch/documents/specrend/
[2] Chris Wyman, Peter-Pike Sloan, and Peter Shirley, Simple Analytic Approximations to the CIE XYZ Color Matching Functions, Journal of Computer Graphics Techniques (JCGT), vol. 2, no. 2, 1-11, 2013. Available online http://jcgt.org/published/0002/02/01/