Newer
Older
GridSampler::GridSampler(const std::shared_ptr<Sampler>& sampler, size_t n)
Vec3 GridSampler::color(float x, float y) const {
Vec3 color(0, 0, 0);
for (int xi = 0; xi < n; xi++) {
for (int yi = 0; yi < n; yi++) {
float xs = x + (xi + 0.5) / n;
float ys = y + (yi + 0.5) / n;
color = color + sampler->color(xs, ys);
}
}
return color / (n * n);