3
$\begingroup$

I have had luck with cosine weighted hemisphere samples, and I know how to generate stratified uniform samples, but I wanted to experiment with combining the two. However, how do I correctly stratify the hemisphere when performing the cosine weighted sampling? Do I cosine-weight the stratification? How many rays do I cast in each stratum?

My application is the collection of indirect samples in a lightmapper.

$\endgroup$
  • $\begingroup$ I needed something similar but used a biased approach in the end: Fibonacci spiral sampling (Quasi-Monte Carlo). $\endgroup$ – Matthias Feb 9 '17 at 11:17
2
$\begingroup$

If you have a deterministic mapping function which transforms uniformly distributed samples into the desired PDF (cosine shaped in your case), just feed it directly with stratified uniformly distributed samples. The mapping will keep the strata separated.

Usually one sample per stratum is used and the number of strata is set according to the total amount of needed samples per one Monte Carlo estimation. More samples per stratum will somehow work too, you just need to make sure that each stratum gets the same amount of samples not to break uniformity of the (input) distribution. Keep in mind, however, that using more samples per stratum will degrade the per-sample performance of the Monte Carlo estimator due to sample clustering which usually happen for simple non-stratified random sampling.

$\endgroup$
  • $\begingroup$ Although it's the case for the obvious mapping here, not all mappings preserve stratification. The Box-Muller transform is a common one which does not. $\endgroup$ – Olivier Feb 9 '17 at 17:58
  • 1
    $\begingroup$ @Olivier Box–Muller maps e.g. disjoint boxes in the 2D input space to disjoint annular sectors of the 2D output space, so it preserves stratification in that sense at least. Do you mean that it doesn't if you consider it as a random 1D mapping? $\endgroup$ – Nathan Reed Feb 9 '17 at 18:12
  • $\begingroup$ I ended up successfully using this technique - I simply used my cosineWeightedSample(u,v) function and stratified my u,v inputs. Thanks $\endgroup$ – Steven Feb 9 '17 at 22:55
  • $\begingroup$ @NathanReed yes, I believe you can put it that way. You can't generate a properly stratified 1D normal distribution with it. I suppose you could consider the 2D output stratified, if in a weird way. $\endgroup$ – Olivier Feb 10 '17 at 0:06
3
$\begingroup$

The classic method is to uniformly sample the disc at the base of your hemisphere and to project your samples upwards on the hemisphere (eg. compute z from x and y). This yields a cosine weighted distribution.

As the projection preserves stratification, you need only use stratified sampling of the disc to get a stratified cosine distribution.

$\endgroup$
  • 1
    $\begingroup$ And where is the stratification? This is just uniform cosine weighted sampling? $\endgroup$ – Matthias Feb 9 '17 at 13:29
  • 1
    $\begingroup$ The projection preserves stratification. I will update the answer with that precision. $\endgroup$ – Olivier Feb 9 '17 at 13:53
  • $\begingroup$ How does one control the number of samples per stratum? Or do we need to? $\endgroup$ – Steven Feb 9 '17 at 14:49
  • 1
    $\begingroup$ @Steven I think you'll usually want one sample per stratum (eg. one sample per grid cell in 2D) to make best use of stratified sampling. Unless you have some reason to use a fixed stratification with a variable number of samples. $\endgroup$ – Olivier Feb 9 '17 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.