hititduck
1 posts

#13800
SampleHemisphere is not uniform 11 months ago
The current SampleHemisphere function does not generate points distributed uniformly on the hemisphere:
Here's an efficient way to generate uniform samples on the unit sphere attributed to Marsaglia (1972).
You can flip the sample's position according to its dot product with a normal as before. 
Pseudonym
Andrew Bromage
184 posts
/ 1 project
Research engineer, resident maths nerd (Erdős number 3). 
#13820
SampleHemisphere is not uniform 11 months ago
Here's a method which involves no loops, due to Archimedes (225 BCE). The idea is to randomly sample the enclosed cylinder then map that onto the sphere or hemisphere.
However, you probably don't actually want to sample the hemisphere uniformly; for light transport, you probably want to include the geometric cosine factor. The easiest way to do this is to randomly sample the unit disk, then map that onto a hemisphere sitting above it.
sub f{($f)[email protected]_;print"$f(q{$f});";}f(q{sub f{($f)[email protected]_;print"$f(q{$f});";}f}); 