Skip to content

Commit

Permalink
hw3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jamespear committed Mar 18, 2024
1 parent 90a5656 commit 19913b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ <h3>
Explain adaptive sampling. Walk through your implementation of the adaptive sampling.
</h3>
<p>
Adaptive sampling is the technique of only sampling in dense areas in order to avoid oversampling in areas that it is not necessary to. Adaptive sampling samples until convergence, at which point sampling will give dimishing returns. In order to implement adaptive sampling, we need to know the density of a distribution of an image, and calculating this distribution involves computing the mean and variance at certain pixel. From these parameters, we can calculate I = 1.96 * sqrt(variance)/sqrt(samples), and we can stop sampling based on the rule I less than equal to maxTolerance * mean, where maxTolerance is a hyperparameter. If this rule is true, we assume our pixel has reached convergence, and we stop sampling.
Adaptive sampling is the technique of only sampling in dense areas in order to avoid oversampling in areas that it is not necessary to. Some pixels converge faster with low sampling rates, while other pixels require many more samples to get rid of noise. It is beneficial for our program to allocate more resources and samples to the more difficult parts of the image rather than sampling uniformly across the entire scene. Adaptive sampling samples until convergence, at which point sampling will give dimishing returns. In order to implement adaptive sampling, we need to know the density of a distribution of an image, and calculating this distribution involves computing the mean and variance at certain pixel. From these parameters, we can calculate I = 1.96 * sqrt(variance)/sqrt(samples), and we can stop sampling based on the rule I less than equal to maxTolerance * mean, where maxTolerance is a hyperparameter. If this rule is true, we assume our pixel has reached convergence, and we stop sampling.
</p>
<p>
In my implementation of adaptive sampling, I kept my original algorithm for rayracing a pixel, but made a few adjustments. I separated my algorithm into two cases: num_samples = 1, and num_samples != 1. If num_samples is 1, I generated a ray based off the normalized coordinates of x and y, set the ray depth to the max_ray_depth, and updated the sample buffer pixel based off the new estimated radiance at this point. If num_samples != 1, I looped through the number of samples. I performed a similar operation of calculating a random sample centered at x and y, normalized this sample, and generated a ray given these coordinates. I set the ray depth to be the current max ray depth. I kept a running sum of the estimated global illumination as well for each of these rays. I calculated the illuminance and illuminance squared, and if the count of my loop at this point was a multiple of my samplesPerBatch (so I do not need to check this every time I loop through), I calculated the mean, variance, and convergence of this sample at this point in the loop. If my convergence is less than the maxTolerance * mean, then I will break out of this loop, as this sample has converged for this point and no extra calculations are necessary. I divide my running sum by the number of counts in order to give an average, and I updated the sampleCountBuffer at this point to the count, and updated the pixel value to the calculated average.
Expand Down

0 comments on commit 19913b2

Please sign in to comment.