POV-Ray : Newsgroups : povray.general : TerraPOV tutorial articles in p.b.t Server Time
27 Nov 2024 03:34:26 EST (-0500)
  TerraPOV tutorial articles in p.b.t (Message 1 to 7 of 7)  
From: Bruno Cabasson
Subject: TerraPOV tutorial articles in p.b.t
Date: 4 May 2009 04:59:38
Message: <op.utedxozzm1sclq@pignouf>
I started the TerraPOV series with a preliminary article in  
povray.binary.tutorials. Hope it is the right place for that. Following:  
TerraPOV's sky system/Atmosphere.

    Bruno


-- 

http://www.opera.com/mail/


Post a reply to this message

From: Ive
Subject: Re: TerraPOV tutorial articles in p.b.t
Date: 7 May 2009 08:26:00
Message: <4a02d358$1@news.povray.org>
Bruno Cabasson wrote:
> I started the TerraPOV series with a preliminary article in 
> povray.binary.tutorials. Hope it is the right place for that. Following: 
> TerraPOV's sky system/Atmosphere.
> 

This is really very much appreciated, thanks a lot. I'm already waiting 
for the next episode ;)

Just one point: The rgb color calculation for the Rayleigh scattering is 
a bit, hmm, let's say problematic. Color conversion from wavelength 
values to any rgb color space should always done by using color 
transformation through the CIE xyz space.

I've quickly implemented it by using a Gaussian distribution around
the wavelength peak values and for the spectrum conversion my old CIE 
include file (part of Jaime's lightsys).


//-----------------------------------------------------

// Atmosphere: scattering color
#declare TP_LAMBDA_RED   = 650; // nanometres
#declare TP_LAMBDA_GREEN = 555; // nanometres
#declare TP_LAMBDA_BLUE  = 460; // nanometres


#include "CIE.inc"

#local TP_FACT_RED   = pow(TP_LAMBDA_BLUE/TP_LAMBDA_RED, 4);
#local TP_FACT_GREEN = pow(TP_LAMBDA_BLUE/TP_LAMBDA_GREEN, 4);
#local TP_FACT_BLUE  = 1;
#local TP_STEP = 5;          // integral step width for spline creation
#local TP_GAUSS_BELL = 45;   // get 95% distribution +/- 45nm around the 
peak value


#macro Gauss(Peak, Value, Fact)
   #local E = 2.7182818284;
   #local D = abs(Peak - Value) / TP_STEP;
   pow(E, -(D*D) / TP_GAUSS_BELL) * Fact
#end


#local TP_RALEIGH_SPECTRUM = spline
{  linear_spline

#local WL = 380;
#while (WL <= 760)
   WL, Gauss(TP_LAMBDA_RED,   WL, TP_FACT_RED) +
       Gauss(TP_LAMBDA_GREEN, WL, TP_FACT_GREEN) +
       Gauss(TP_LAMBDA_BLUE,  WL, TP_FACT_BLUE)

   #local WL = WL + TP_STEP;
#end
}


#declare TP_RAYLEIGH_SCATTERING_COLOR = 
EmissiveSpectrum(TP_RALEIGH_SPECTRUM);


//-----------------------------------------------------


Your calculation

#declare TP_RAYLEIGH_SCATTERING_COLOR = rgb 
<pow(TP_LAMBDA_BLUE/TP_LAMBDA_RED, 4), 
pow(TP_LAMBDA_BLUE/TP_LAMBDA_GREEN, 4),
1>;

gives

rgb <0.2508, 0.4719, 1.0000>

and my version

rgb <0.2625, 0.4436, 1.0000>


so the difference is subtle - but especially when the sun altitude is 
very low - noticeable. It looks slightly less 'greenish'.


Anyway, as said, I can hardly wait for the next part of your tutorial

-Ive


Post a reply to this message

From: Bruno Cabasson
Subject: Re: TerraPOV tutorial articles in p.b.t
Date: 7 May 2009 09:33:02
Message: <op.utkalabtm1sclq@pignouf>


> Bruno Cabasson wrote:
>> I started the TerraPOV series with a preliminary article in  
>> povray.binary.tutorials. Hope it is the right place for that.  
>> Following: TerraPOV's sky system/Atmosphere.
>>
>
> This is really very much appreciated, thanks a lot. I'm already waiting  
> for the next episode ;)
>
> Just one point: The rgb color calculation for the Rayleigh scattering is  
> a bit, hmm, let's say problematic. Color conversion from wavelength  
> values to any rgb color space should always done by using color  
> transformation through the CIE xyz space.
>
> I've quickly implemented it by using a Gaussian distribution around
> the wavelength peak values and for the spectrum conversion my old CIE  
> include file (part of Jaime's lightsys).
>
>
> //-----------------------------------------------------
>
> // Atmosphere: scattering color
> #declare TP_LAMBDA_RED   = 650; // nanometres
> #declare TP_LAMBDA_GREEN = 555; // nanometres
> #declare TP_LAMBDA_BLUE  = 460; // nanometres
>
>
> #include "CIE.inc"
>
> #local TP_FACT_RED   = pow(TP_LAMBDA_BLUE/TP_LAMBDA_RED, 4);
> #local TP_FACT_GREEN = pow(TP_LAMBDA_BLUE/TP_LAMBDA_GREEN, 4);
> #local TP_FACT_BLUE  = 1;
> #local TP_STEP = 5;          // integral step width for spline creation
> #local TP_GAUSS_BELL = 45;   // get 95% distribution +/- 45nm around the  
> peak value
>
>
> #macro Gauss(Peak, Value, Fact)
>    #local E = 2.7182818284;
>    #local D = abs(Peak - Value) / TP_STEP;
>    pow(E, -(D*D) / TP_GAUSS_BELL) * Fact
> #end
>
>
> #local TP_RALEIGH_SPECTRUM = spline
> {  linear_spline
>
> #local WL = 380;
> #while (WL <= 760)
>    WL, Gauss(TP_LAMBDA_RED,   WL, TP_FACT_RED) +
>        Gauss(TP_LAMBDA_GREEN, WL, TP_FACT_GREEN) +
>        Gauss(TP_LAMBDA_BLUE,  WL, TP_FACT_BLUE)
>
>    #local WL = WL + TP_STEP;
> #end
> }
>
>
> #declare TP_RAYLEIGH_SCATTERING_COLOR =  
> EmissiveSpectrum(TP_RALEIGH_SPECTRUM);
>
>
> //-----------------------------------------------------
>
>
> Your calculation
>
> #declare TP_RAYLEIGH_SCATTERING_COLOR = rgb  
> <pow(TP_LAMBDA_BLUE/TP_LAMBDA_RED, 4),  
> pow(TP_LAMBDA_BLUE/TP_LAMBDA_GREEN, 4),
> 1>;
>
> gives
>
> rgb <0.2508, 0.4719, 1.0000>
>
> and my version
>
> rgb <0.2625, 0.4436, 1.0000>
>
>
> so the difference is subtle - but especially when the sun altitude is  
> very low - noticeable. It looks slightly less 'greenish'.
>
>
> Anyway, as said, I can hardly wait for the next part of your tutorial
>
> -Ive

Thanks for reading me, Ive!  :)

You are right. Thanks for the tip!

The rgb-wavelength correspondance has been the subject of endless  
discussions and studies. The values I gave in the tutorial were quite  
'arbitrary', and can be modified at will. I said in the tutorial that the  
colors were not 100% satisfactory yet. They are indeed too reddish and  
greenish (saturation too low). This can be tuned by setting different  
values for the three wavelengths.

Plus, the atmosphere is more complex than  
only-air-molecules-with-only-rayleigh-scattering, and contains many types  
of molecules. These molecules produce an additional scattering and an  
additional absorption. This will correct colors, allows tuning and express  
different situations (pollution, sea, mountain, desert, etc ...). TerraPOV  
lets the user set the values of these scattering and absorption.

I needed a start point for the scattering color of TerraPOV's atmosphere.  
If you have a clear idea for rgb-wavelength correspondance, and if you can  
provide 3 values for TerraPOV's default, I will be very happy and  
thankful  :p .

Searching the web, I found these links:

http://www.handprint.com/LS/CVS/color.html
http://mintaka.sdsu.edu/GF/explain/optics/rendering.html
http://www.babelcolor.com/download/A%20review%20of%20RGB%20color%20spaces.pdf

I overflew the first two. I'll take a closer look at the pdf.


Bruno

-- 

http://www.opera.com/mail/


Post a reply to this message

From: Ive
Subject: Re: TerraPOV tutorial articles in p.b.t
Date: 9 May 2009 05:06:39
Message: <4a05479f@news.povray.org>
Bruno Cabasson wrote:
> Thanks for reading me, Ive!  :)
> 
It's my pleasure.


> I needed a start point for the scattering color of TerraPOV's 
> atmosphere. If you have a clear idea for rgb-wavelength
> correspondance, and if you can provide 3 values for TerraPOV's
> default, I will be very happy and thankful  :p .
> 

Well, forget my last post, guess I was still sleepy. In fact selecting
three wavelength values will *always* be arbitrary as you can calculate 
the RGB value for a given wavelength or spectrum, but not the other way 
around.
But this is not needed because - we can simply calculate the RGB value
from the spectral data itself. It can be done within the SDL with this
few lines of code:

//******************************************************

#include "CIE.inc"

// Create spectral data for Raleigh scattering following
// the power of 4 rule. Range from 380 to 830 nm.

#declare TP_RALEIGH_SPECTRUM = spline
{
   linear_spline

   #local WL = 380;

   #while (WL < 830)
     WL, pow(380/WL, 4)
     #local WL = WL + 5;
   #end
}

// Calculate the RGB value by using the CIE color match

// color space (sRGB/ITU primaries, whitepont D65 but
// without gamma correction)

#declare TP_RAYLEIGH_SCATTERING_COLOR = 
EmissiveSpectrum(TP_RALEIGH_SPECTRUM);

//*****************************************************


This gives for TP_RAYLEIGH_SCATTERING_COLOR the value of

rgb <0.2978, 04382, 1.0000>


This is a little less greenish than your result. But I must admit that 
your *arbitrary* value did come quite close and where well chosen ;)

Anyway, feel free to use this color science approach or just keep your
arbitrary values because I guess for the final result with a more 
complex atmosphere model the visible difference will be minor.

Still waiting for the next part of your tutorial ;)

-Ive


Post a reply to this message

From: Christian Froeschlin
Subject: Re: TerraPOV tutorial articles in p.b.t
Date: 9 May 2009 06:21:28
Message: <4a055928$1@news.povray.org>
> rgb <0.2978, 04382, 1.0000>

It's probably safe to assume that this should be 0.4382 ...

> This is a little less greenish than your result.

... or the difference in greenishness would be more pronounced ;)


Post a reply to this message

From: Ive
Subject: Re: TerraPOV tutorial articles in p.b.t
Date: 9 May 2009 06:27:12
Message: <4a055a80$1@news.povray.org>
Christian Froeschlin wrote:
>> rgb <0.2978, 04382, 1.0000>
> 
> It's probably safe to assume that this should be 0.4382 ...
> 

err, yes, its safe ;) sorry.

-Ive


Post a reply to this message

From: Bruno Cabasson
Subject: Re: TerraPOV tutorial articles in p.b.t
Date: 11 May 2009 06:10:00
Message: <web.4a07f88946a6ddb04aa45fdf0@news.povray.org>
Ive <"ive### [at] lilysoftorg"> wrote:
> Bruno Cabasson wrote:
> > Thanks for reading me, Ive!  :)
> >
> It's my pleasure.
>
>
> > I needed a start point for the scattering color of TerraPOV's
> > atmosphere. If you have a clear idea for rgb-wavelength
> > correspondance, and if you can provide 3 values for TerraPOV's
> > default, I will be very happy and thankful  :p .
> >
>
> Well, forget my last post, guess I was still sleepy. In fact selecting
> three wavelength values will *always* be arbitrary as you can calculate
> the RGB value for a given wavelength or spectrum, but not the other way
> around.
> But this is not needed because - we can simply calculate the RGB value
> from the spectral data itself. It can be done within the SDL with this
> few lines of code:
>
> //******************************************************
>
> #include "CIE.inc"
>
> // Create spectral data for Raleigh scattering following
> // the power of 4 rule. Range from 380 to 830 nm.
>
> #declare TP_RALEIGH_SPECTRUM = spline
> {
>    linear_spline
>
>    #local WL = 380;
>
>    #while (WL < 830)
>      WL, pow(380/WL, 4)
>      #local WL = WL + 5;
>    #end
> }
>
> // Calculate the RGB value by using the CIE color match

> // color space (sRGB/ITU primaries, whitepont D65 but
> // without gamma correction)
>
> #declare TP_RAYLEIGH_SCATTERING_COLOR =
> EmissiveSpectrum(TP_RALEIGH_SPECTRUM);
>
> //*****************************************************
>
>
> This gives for TP_RAYLEIGH_SCATTERING_COLOR the value of
>
> rgb <0.2978, 04382, 1.0000>
>
>
> This is a little less greenish than your result. But I must admit that
> your *arbitrary* value did come quite close and where well chosen ;)
>
> Anyway, feel free to use this color science approach or just keep your
> arbitrary values because I guess for the final result with a more
> complex atmosphere model the visible difference will be minor.
>
> Still waiting for the next part of your tutorial ;)
>
> -Ive

Thank you very much for those enlightments! I first chose my values by looking
at a sRGB xy chart, and trying visually to see what are the 'closest'
wavelengths to the 3 primaries by drawing an imaginary line from D65 white
point to the monochromatic path and passing by the 3 sRGB primaries. I do not
really know if this trick is physically correct (I guess it is not ...). But at
first I did not wonder much about it, because I knew I was not so far from
correct values, and the user can control those at will. BUT: I read somewhere
on the web that atmosphere's behaviour may depend on the elevations, meaning
that the 'correct default' parameters could be different for each case...

I think I'll put CMF values from CIE.inc into a spreadsheet, draw a precise
chart and have better graphical intersections. We will see how far it will be
from your values. However,

But, anyway, I think your values are better and more physically correct, and
I'll take them for TerraPOV.

newt article coming soon (quite busy with family life this week-end).

Thank you again.

Bruno.


Post a reply to this message

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