POV-Ray : Newsgroups : povray.general : spherical light math help ... : Re: spherical light math help ... Server Time
10 Aug 2024 11:24:01 EDT (-0400)
  Re: spherical light math help ...  
From: Chris Huff
Date: 7 Jan 2000 13:22:32
Message: <chrishuff_99-F7EACC.13224207012000@news.povray.org>
I don't know how to solve that problem, other than storing all the 
possible positions in an array and counting the ones inside the sphere. 
So here is an alternate method:

#declare rsA = seed(7892983);
#macro SphereLight(SourceNum, Center, Rad, Color)
   #local J=0;
   #while(J<SourceNum)
      #local Pos = < rand(rsA)*2*Rad - Rad,
               rand(rsA)*2*Rad - Rad,
               rand(rsA)*2*Rad - Rad>;
      #if(vlength(Pos)<=Rad)
         light_source {Pos color Color/SourceNum translate Center}
         #local J=J+1;
      #end
   #end
#end

The light sources are placed randomly inside the sphere, which makes any 
patterns or banding less visible. Be careful, though, large numbers of 
light sources can really slow things. I tested it with this little scene:

#include "colors.inc"
camera {
   location <-3, 5, -8>
   look_at < 0, 0, 0>
   angle 35
}

#declare T_Green = texture {pigment {color Green}}

SphereLight(100, < 0, 5, 0>, 1, White)

sphere {< 0, 1, 0>, 1
   texture {T_Green} 
}
box {<-100, 0,-100>, < 100, 0, 100>
   pigment {color Gray80}
}

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

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