POV-Ray : Newsgroups : povray.beta-test : Photons are broken with true inverse squared lighting : Re: Photons are broken with true inverse squared lighting Server Time
27 Jul 2024 08:00:00 EDT (-0400)
  Re: Photons are broken with true inverse squared lighting  
From: William F Pokorny
Date: 20 Jun 2024 09:39:33
Message: <66743115$1@news.povray.org>
On 6/19/24 18:16, William F Pokorny wrote:
> I'll look at this tomorrow.

In source/core/lighting/photons.cpp there are two methods:

     void PhotonTrace::addSurfacePhoton()

     void PhotonMediaFunction::addMediaPhoton()

which have code like:

     if ((photonLight->Fade_Power > 0.0) &&
         (fabs(photonLight->Fade_Distance) > gkMinIsectDepthReturned))
     {
         Attenuation = 2.0 /
         (1.0 + pow(threadData->photonDepth /
             photonLight->Fade_Distance, photonLight->Fade_Power)
         );
     }
     else
         Attenuation = 1;

In both methods, the code needs to be something like:

     if (photonLight->Fade_Power > 0.0)
     {
         if (fabs(photonLight->Fade_Distance) >= gkMinIsectDepthReturned)
         {
             Attenuation = 2.0 /
                 (1.0 + powf(threadData->photonDepth /
                             photonLight->Fade_Distance,
                             photonLight->Fade_Power
                        )
                 );
         }
         else if (threadData->photonDepth >= gkMinIsectDepthReturned)
         {
             Attenuation =
                 powf(threadData->photonDepth,-photonLight->Fade_Power);
         }
         else
         {
             Attenuation = 0.0;
         }
     }
     else if (photonLight->Fade_Power == 0)
     {
         Attenuation = 1;
     }
     else
     {
         Attenuation = 0.0;
     }

Bill P.

Aside: I moved pow to powf as the latter often much faster and float 
accuracy is fine for attenuation. It might be official releases are 
already running 'pow()' with floats without code that forces it.


Post a reply to this message

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