POV-Ray : Newsgroups : povray.binaries.images : Refraction & Dispersion Example : Re: Refraction & Dispersion Example Server Time
31 Jul 2024 12:23:49 EDT (-0400)
  Re: Refraction & Dispersion Example  
From: clipka
Date: 29 Oct 2009 09:52:38
Message: <4ae99e26@news.povray.org>
Ive schrieb:

> It seems the code tries to mimic the CIE CMF (color matching function)
> within r,g,b values. Note the two peaks of the red component. I do not
> know how well this is done but I do see two problems:
> CIE reference white is D50 and not D65 as within s(c)RGB and the CMF 
> tables of course refer to the CIE xyz color space.

Shouldn't the white point issue be addressed properly by the standard 
XYZ->sRGB color space mapping?

Presuming of course that this (or something similar) was done by the 
author of the function.


>> I tried to replace the formula with an interpolation table generated 
>> from physical data normalized to the sRGB color space, but it looked 
>> even worse.
> 
> ???

Step 1: Grab the CIE tristimulus data. I would have expected this to 
have given me spectral band colors in CIE XYZ color space.

Step 2: Convert CIE XYZ colors to sRGB primaries and white point using 
the matrix as defined in the sRGB standard

Step 3: Fix gamut.


>> (I did replace the formula with a table though - using values 
>> generated directly from the formula for now - as this was needed to 
>> address the "color drift" that occurred with low dispersion sample 
>> count.)
> 
> As an accurate in place calculation is quite computing intensive and as 
> you have already implemented a LUT it should be fairly easy to fill it 
> with accurate rgb values depending on the wavelength by using a bit of 
> POV-Ray SDL from my CIE.inc file and the macro
> Wavelength2RGB(wavelength) from there.

That's one reason (of multiple) why I modified the code to use a LUT now.

You got something already? Hey, me wants that!
Ah, you even included code... neat. I'll give it a try, thanks!


> Should be used with the default settings (sRGB primaries,
> D65 whitepoint, D50 reference white and Bradford chromatic adaption).

Ah, um... which means?

Well, never mind - I guess it'll be substantial enough to at least give 
me a hint what to google for.


> It will fulfill the criteria that integrating over all samples will 
> result in *white*. The values close to UV and IR will become darker (as 
> they should) so the violet peak you did observe should disappear.
> 
> As I have not the faintest idea how the POV-Ray photon code is working
> a few additional notes:
> The values that are returned from 'Wavelength2RGB' are NOT normalized, 
> so maybe there should be a constant multiplier for all values (to make 
> them exactly fit into the 0.0 - 1.0 range).
> The values that are chosen for WL_MIN and WL_MAX (or better how the 
> dispersion samples within POV-Ray are spread out) will have a huge 
> impact on the visual appearance, so for a low count of dispersion 
> samples they should be limited to only spread from e.g. 440nm to 640nm
> (but only guessing here, has to be tried out).

The approach used by POV-Ray 3.6 (and 3.7 up intil beta.34) was to 
spread from what could have been 380 nm to something like 730 nm; for a 
3-sample dispersion it would then take wavelengths 380 nm, 555 nm and 
730 nm. Which is obviously highly bogus because 380 nm and 730 nm are 
virtually black already.

My current approach differs in two respects:

(1) As far as refraction angles are concerned, I allow for a 
half-"bandwidth" marging near the edges of the visible spectrum; that 
is, for instance with a 3-sample dispersion, sample rays will be assumed 
to have wavelengths of 438 nm, 555 nm, and 672 nm, respectively.

(2) As far as sample ray colors are concerned, I'm not using /sample/ 
colors, but /integrated/ colors; that is, for instance in the 3-sample 
dispersion example, the 438 nm ray would be colored as if it was a 
bundle of rays from 380 to 497 nm; the 555 nm ray would be colored like 
a bundle of rays from 497 nm to 613 nm; and the 672 nm ray would be 
colored like a bundle of rays from 613 to 730 nm.

The lookup table is already adapted for this purpose, storing integrals 
of the colors from 380 nm to X in steps of 5 nm; an individual ray will 
then be colored by looking up two values from the table (for the ray's 
nominal wavelength plus/minus half its "bandwidth"), and coloring the 
ray according to the difference.


> So even if the values returned by Wavelength2RGB are perfectly accurate 
> there will be some trial and error involved to find visually good 
> looking values for the min and max dispersion spread especially when 
> only few samples are used.

I think the integration approach does not suffer from this problem at all.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.