Soft shadows: light source of a spherical region

I am trying to implement soft shadows in my raytracer. To do this, I plan to shoot multiple rays of shadow from the intersection point to the light source of the area. I am trying to use a spherical region of light - this means that I need to create random points on the sphere for the direction vector of my ray (recall that the ray is given with the beginning and direction).

I was looking for ways to create an even distribution of random points on a sphere, but they seem a little more complicated than what I'm looking for. Does anyone know of any methods for creating these points on a sphere? I believe that the light source of the sphere sphere will simply be determined by its XYZ world coordinates, RGB color value and r-radius.

Thank you and I appreciate the help!

+4
source share
2 answers

Gems III Graphics, p. 126:

void random_unit_vector(double v[3]) { double theta = random_double(2.0 * PI); double x = random_double(2.0) - 1.0; double s = sqrt(1.0 - x * x); v[0] = x; v[1] = s * cos(theta); v[2] = s * sin(theta); } 

(This is the second of four methods cited in a MathWorld article, "Selecting a Sphere . "

ETA: if a sphere of radius r is centered on O , and u is a random unit vector, then a random point on the surface of the sphere is O + r u .

+5
source

Many good formulas for random distributions are found in the Global Collection of Illustrations . Part 4.B. has formulas for generating points on a (hemi) sphere. This is a great link to fetch, integration, etc.

0
source

All Articles