Frame buffer for spectral rendering

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

Frame buffer for spectral rendering

Post by raider » Tue Nov 26, 2013 9:36 pm

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

Post by ypoissant » Tue Nov 26, 2013 10:58 pm

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

Post by toshiya » Wed Nov 27, 2013 11:28 am

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

Post by Serendipity » Wed Nov 27, 2013 2:01 pm

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

Post by ingenious » Wed Nov 27, 2013 2:55 pm

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

Post by raider » Wed Nov 27, 2013 10:13 pm

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

Post by friedlinguini » Wed Nov 27, 2013 11:39 pm


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

Re: Frame buffer for spectral rendering

Post by spectral » Thu Nov 28, 2013 8:06 am

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

Post by toshiya » Thu Nov 28, 2013 9:58 am

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.

Post Reply