## Frame buffer for spectral rendering

Practical and theoretical implementation discussion.
raider
Posts: 42
Joined: Fri Aug 03, 2012 10:36 pm
Location: Moscow, Russia.

### Frame buffer for spectral rendering

When sampling wavelengths, am I right that frame buffer have to accumulate values in some linear color space like CIE XYZ, and only the final image to be converted to let's say sRGB? I mean can't accumulate pixel intensity directly in sRGB as it incorporates some transfer function (gamma curve), so that two sRGB values can't be simply added to represent resulting color from two samples.

ypoissant
Posts: 97
Joined: Wed Nov 30, 2011 12:44 pm

### Re: Frame buffer for spectral rendering

It is easy to linearize sRGB by de-gammaing it.

The color pipeline I use is:
1- degamma all colors (textures and colors specified as RGB from the user) when they are read from file or from input fields.
2- Do all rendering calculation using those linearized RGB colors.
3- Accumulate those RGB results in the frame buffer
4- Apply gamma to frame buffer data while transfering them to output.

toshiya
Posts: 22
Joined: Tue Apr 03, 2012 1:42 pm

### Re: Frame buffer for spectral rendering

The correct order is, accumulation, tone mapping, and then gamma/color correction.

You can think of accumulation of spectral contributions as a part of Monte Carlo integration, which should be done before any image processing like tone mapping and gamma correction.

Having said that, if you can easily invert your tone mapping and gamma correction functions, you can store the final image as a frame buffer, de-gamma correct and de-tone map it, accumulate values, and then tone map and gamma correct it to do the right thing as suggested :->

Serendipity
Posts: 37
Joined: Mon Dec 19, 2011 9:50 pm

### Re: Frame buffer for spectral rendering

The more interesting question to me here is: How much do you loose by accumulating the values in XYZ instead of accumulating them in a true spectral buffer and convert the accumulated result afterwards? Especially with fluorescence this would be very interesting to evaluate.

ingenious
Posts: 282
Joined: Mon Nov 28, 2011 11:11 pm
Location: London, UK
Contact:

### Re: Frame buffer for spectral rendering

Serendipity wrote:How much do you loose by accumulating the values in XYZ instead of accumulating them in a true spectral buffer and convert the accumulated result afterwards?
I suppose this depends on the spectral resolution of the (spectral) buffer. If you only use 3 spectral bins, I wouldn't be surprised if you get a less accurate result than when accumulating in XYZ.

raider
Posts: 42
Joined: Fri Aug 03, 2012 10:36 pm
Location: Moscow, Russia.

### Re: Frame buffer for spectral rendering

Thank you guys! It's clear for me on the framebuffer. Now, what about converting RGB textures to spectral representation? There is no unique transform from RGB to spectrum. So what is good approach here? to use scaled color matching functions or something else?

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

### Re: Frame buffer for spectral rendering

spectral
Posts: 382
Joined: Wed Nov 30, 2011 2:27 pm
Contact:

### Re: Frame buffer for spectral rendering

Yes, there is this paper... but don't forget that your image will not completly match the spectral generated one. If you use a language like C++ it is easy to have a kind of "Spectrum" color class to handle everything, you can easily switch between the RGB/XYZ and the spectral model.
This way you can compare the results and speed.

toshiya
Posts: 22
Joined: Tue Apr 03, 2012 1:42 pm

### Re: Frame buffer for spectral rendering

I also have a code that does RGB <-> spectrum conversions in my gpusppm:

http://cs.au.dk/~toshiya/gpusppm.zip

I've tested the code and it should be fairly accurate in the sense that RGB -> spectrum -> RGB well recovers the original RGB value. It's based on that paper with some improvement.