POV-Ray : Newsgroups : povray.general : TerraPOV tutorial articles in p.b.t : Re: TerraPOV tutorial articles in p.b.t Server Time
30 Jul 2024 08:22:30 EDT (-0400)
  Re: TerraPOV tutorial articles in p.b.t  
From: Ive
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

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