POV-Ray : Newsgroups : povray.advanced-users : Lightsys IV and SpectralRender yield different light levels Server Time
20 Apr 2024 00:40:22 EDT (-0400)
  Lightsys IV and SpectralRender yield different light levels (Message 1 to 7 of 7)  
From: Cousin Ricky
Subject: Lightsys IV and SpectralRender yield different light levels
Date: 25 Jul 2016 14:20:00
Message: <web.5796572fda17689bb484452a0@news.povray.org>
Not satisfied with the lighting options in SpectralRender, I decided write a
module that would prepare arbitrary spectra for SpectralRender.  I also decided
to match the luminance of renders in preview and spectral modes, which meant
forsaking the hardwired normalization of CIE.inc::Emissive2xyz().  I wrote my
own normalization procedures to sync the 2 modes, and that's when things started
to get weird.

If I normalized on xyz (as Emissive2xyz() does), the preview rendered as
expected, but the spectral render was way too bright.  If I tried to normalize
the spectrum itself or left it unnormalized, the spectral render was perfect,
but the preview was way too dim.

I would like to add my module to the Object Collection, and this one issue is
holding it up.

After some investigation, it seems to me that there is some discrepancy between
CIE.inc and SpectralComposer.pov in the way they convert spectral curves to xyz,
although I lack the expertise in color theory to find it.

The difference is illustrated by the following scene:

----------[BEGIN CODE]----------
#version 3.7;

#declare LEVEL = 0.5;

#if (clock_on)

  #include "spectral.inc"

  global_settings { assumed_gamma 1 }

  #declare Illuminant = array[36]
  #for (I, 0, 35)
    #declare Illuminant[I] = LEVEL; // Illuminant E
  #end

  background { SpectralEmission (Illuminant) }

#else

  #declare FName = "light_level"
  #include "SpectralComposer.pov"

  #declare Acc = <0, 0, 0>;
  #for (I, 0, 35)
    #local Wl = 380 + I * 10;
    #declare Acc = Acc + CMF_xyz (Wl) * LEVEL; // Illuminant E
  #end
  #declare C = Acc / 36;
  #debug concat ("xyz <", vstr (3, C, ", ", 0, 4), ">\n")
  #debug concat ("rgb <", vstr (3, xyz2RGB (C), ", ", 0, 4), ">\n")

#end
-----------[END CODE]-----------

The text output is:

xyz <0.1484, 0.1484, 0.1483>
rgb <0.1788, 0.1408, 0.1347>

However, a sampling of the output image yields:

rgb <0.6436, 0.5068, 0.4851>

The difference is a factor of about 3.6.  Is this just the way it's supposed to
be, or did I miss something?


Post a reply to this message

From: scott
Subject: Re: Lightsys IV and SpectralRender yield different light levels
Date: 27 Jul 2016 05:29:09
Message: <57987ee5$1@news.povray.org>
>   #declare Acc = <0, 0, 0>;
>   #for (I, 0, 35)
>     #local Wl = 380 + I * 10;
>     #declare Acc = Acc + CMF_xyz (Wl) * LEVEL; // Illuminant E
>   #end
>   #declare C = Acc / 36;

What units are the return value from CMF_xyz (specifically, is it nm^-1 
or does it return the xyz for a 10nm band width)? I suspect you need to 
multiply the value by 10 if you are using 10 nm width spectral bands.

Also I don't see why you need the Acc/36 line, the result should be the 
sum of all the wavelength contributions, not the average.

If you change those two things, does the below give the correct result?

#declare Acc = <0, 0, 0>;
#for (I, 0, 35)
   #local Wl = 380 + I * 10;
   #declare Acc = Acc + CMF_xyz (Wl) * 10 * LEVEL; // Illuminant E
   #end
#declare C = Acc;


Post a reply to this message

From: Cousin Ricky
Subject: Re: Lightsys IV and SpectralRender yield different light levels
Date: 27 Jul 2016 22:31:06
Message: <57996e6a$1@news.povray.org>
On 2016-07-27 05:29 AM (-4), scott wrote:
>>   #declare Acc = <0, 0, 0>;
>>   #for (I, 0, 35)
>>     #local Wl = 380 + I * 10;
>>     #declare Acc = Acc + CMF_xyz (Wl) * LEVEL; // Illuminant E
>>   #end
>>   #declare C = Acc / 36;
>
> What units are the return value from CMF_xyz (specifically, is it nm^-1
> or does it return the xyz for a 10nm band width)? I suspect you need to
> multiply the value by 10 if you are using 10 nm width spectral bands.
>
> Also I don't see why you need the Acc/36 line, the result should be the
> sum of all the wavelength contributions, not the average.
>
> If you change those two things, does the below give the correct result?
>
> #declare Acc = <0, 0, 0>;
> #for (I, 0, 35)
>   #local Wl = 380 + I * 10;
>   #declare Acc = Acc + CMF_xyz (Wl) * 10 * LEVEL; // Illuminant E
>   #end
> #declare C = Acc;

It's even worse:

xyz <53.4116, 53.4265, 53.3845>
rgb <64.3517, 50.6749, 48.5072>

This suggests I should divide by 10 instead of multiplying by 10, but I 
don't know why that should be.


Post a reply to this message

From: scott
Subject: Re: Lightsys IV and SpectralRender yield different light levels
Date: 28 Jul 2016 03:18:09
Message: <5799b1b1$1@news.povray.org>
>> What units are the return value from CMF_xyz (specifically, is it nm^-1
>> or does it return the xyz for a 10nm band width)? I suspect you need to
>> multiply the value by 10 if you are using 10 nm width spectral bands.
>>
>> Also I don't see why you need the Acc/36 line, the result should be the
>> sum of all the wavelength contributions, not the average.
>>
>> If you change those two things, does the below give the correct result?
>>
>> #declare Acc = <0, 0, 0>;
>> #for (I, 0, 35)
>>   #local Wl = 380 + I * 10;
>>   #declare Acc = Acc + CMF_xyz (Wl) * 10 * LEVEL; // Illuminant E
>>   #end
>> #declare C = Acc;
>
> It's even worse:
 >
> xyz <53.4116, 53.4265, 53.3845>
> rgb <64.3517, 50.6749, 48.5072>

It's quite common in colour stuff to use a scale of 0-100 (per cent) 
rather than 0-1. It seems like this is what is happening here. You just 
need to divide by 100 to match the units of your image sampling.

You definitely don't want to divide by 10, that is unrelated, and just a 
fudge that will happen to work because you are using 10nm bands (and 
10*10=100). You need to multiply by the band width to get the correct 
result. For example, if you happened to use 5nm bands:

#declare Acc = <0, 0, 0>;
#for (I, 0, 70)
   #local Wl = 380 + I * 5;
   #declare Acc = Acc + CMF_xyz (Wl) * 5 * LEVEL; // Illuminant E
   #end
#declare C = Acc / 100; // convert from % to 0...1 scale

You should get the same answer (roughly) for any reasonable bandwidth 
you decide to use.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Lightsys IV and SpectralRender yield different light levels
Date: 28 Jul 2016 21:35:35
Message: <579ab2e7$1@news.povray.org>
On 2016-07-28 03:18 AM (-4), scott wrote:
> It's quite common in colour stuff to use a scale of 0-100 (per cent)
> rather than 0-1. It seems like this is what is happening here. You just
> need to divide by 100 to match the units of your image sampling.
>
> You definitely don't want to divide by 10, that is unrelated, and just a
> fudge that will happen to work because you are using 10nm bands (and
> 10*10=100). You need to multiply by the band width to get the correct
> result. For example, if you happened to use 5nm bands:
>
> #declare Acc = <0, 0, 0>;
> #for (I, 0, 70)
>   #local Wl = 380 + I * 5;
>   #declare Acc = Acc + CMF_xyz (Wl) * 5 * LEVEL; // Illuminant E
>   #end
> #declare C = Acc / 100; // convert from % to 0...1 scale
>
> You should get the same answer (roughly) for any reasonable bandwidth
> you decide to use.

Since the macro I'm writing works on SpectralRender arrays, that 10 nm 
is not going to change.  Nevertheless, I will follow your advice for 
clarity's sake.  However, I'm moving the 10 outside the loop:

#declare Acc = <0, 0, 0>;
#for (I, 0, 35)
   #local Wl = 380 + I * 10;
   #declare Acc = Acc + CMF_xyz (Wl) * LEVEL; // Illuminant E
#end
#declare C = Acc * 10 / 100; // convert from % to 0...1 scale

(The production macro also loses the temporary variable Wl.  It appears 
in my example only because of a carryover from my debugging.)


Post a reply to this message

From: Cousin Ricky
Subject: Re: Lightsys IV and SpectralRender yield different light levels
Date: 29 Jul 2016 02:00:06
Message: <web.579af069c6affb00b484452a0@news.povray.org>
Scott, are you the same scott who wrote SkySim?


Post a reply to this message

From: scott
Subject: Re: Lightsys IV and SpectralRender yield different light levels
Date: 29 Jul 2016 03:20:48
Message: <579b03d0$1@news.povray.org>
> Scott, are you the same scott who wrote SkySim?

Yes!


Post a reply to this message

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