This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <random> | |
/* This implements the pseudo-code from http://graphics.pixar.com/library/ProgressiveMultiJitteredSampling/ | |
*/ | |
/* replace with your desired random number generator */ | |
static std::random_device rd; | |
static std::mt19937 rng(rd()); | |
static std::uniform_real_distribution<> dis(0, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static float rnd() | |
{ | |
return drand48(); | |
} | |
float2 generate_sample_point(float i, float j, float xhalf, float yhalf, float n) | |
{ | |
float2 pt; | |
pt.x = (i + 0.5f * (xhalf + rnd())) / n; | |
pt.y = (j + 0.5f * (yhalf + rnd())) / n; |