CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing?...
Transcript of CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing?...
![Page 1: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/1.jpg)
CS 6958
LECTURE 13
INTRO TO ANTI-ALIASING,
PATHTRACING
March 3, 2014
![Page 2: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/2.jpg)
What is Aliasing? 2
Imagine this is our scene
Source: Physically Based Rendering, Pharr & Humphreys
![Page 3: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/3.jpg)
What is Aliasing? 3
If we render it with our ray tracers…
Source: Physically Based Rendering, Pharr & Humphreys
![Page 4: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/4.jpg)
What is Aliasing? 4
If we render it with our ray tracers…
Source: Physically Based Rendering, Pharr & Humphreys
![Page 5: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/5.jpg)
What is Aliasing? 5
Consider our Cornell Box
![Page 6: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/6.jpg)
What is Aliasing? 6
Consider our Cornell Box
![Page 7: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/7.jpg)
What is Aliasing? 7
Consider our Cornell Box
![Page 8: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/8.jpg)
Anti-Aliasing
Issue:
Our sampling can’t reconstruct original signal
Nyquist-Shannon sampling theorem
Solution:
better sampling
better reconstruction of original signal
Lots of literature and theory on sampling and
reconstruction techniques
8
![Page 9: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/9.jpg)
Sampling Techniques
currently: through center of each pixel
1 sample not enough! Use many and “average”
how do we pick samples?
uniform
random
jittered
9
![Page 10: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/10.jpg)
Consider a 2x2 image 10
-1 0 1
0
1
Pixel
![Page 11: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/11.jpg)
Pixel centers 11
-1 0 1
0
1
(-0.5, -0.5) (-0.5, 0.5)
(-0.5, 0.5) (0.5, 0.5)
![Page 12: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/12.jpg)
Pixel centers
foreach pixel(i, j)
x = 2.0f *
(j - xres/2.f + 0.5f)/xres;
y = 2.0f *
(i - yres/2.f + 0.5f)/yres;
This is our current
ray generation method
12
-1 0 1
0
1
(-0.5, -0.5) (-0.5, 0.5)
(-0.5, 0.5) (0.5, 0.5)
![Page 13: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/13.jpg)
Sampling a pixel
pick location other
than center
or perturb center
stop when n reached
13
-1 0 1
0
1
(-0.5, -0.5) (-0.5, 0.5)
(-0.5, 0.5) (0.5, 0.5)
![Page 14: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/14.jpg)
Generating pixel samples
inv_width = loadf(0, 2)
inv_height = loadf(0, 5)
14
(x, y)
x + 1/width
y - 1/height
x - 1/width
y - 1/height
x + 1/width
y + 1/height
x - 1/width
y - 1/height
![Page 15: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/15.jpg)
Generating pixel samples
// value between 0, 1
x_off = (trax_rand() - .5f) * 2.f;
y_off = (trax_rand() - .5f) * 2.f;
// scale offsets to pixel coords
x_off *= inv_width;
y_off *= inv_height;
// offset from center
x += x_off; y += y_off;
// generate ray
camera.makeRay(ray, x, y);
15
(x, y)
inv_
heig
ht
inv_width
![Page 16: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/16.jpg)
Different sampling strategies 16
uniform
Source: Physically Based Rendering, Pharr & Humphreys
![Page 17: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/17.jpg)
Different sampling strategies 17
uniform random
Source: Physically Based Rendering, Pharr & Humphreys
![Page 18: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/18.jpg)
Different sampling strategies 18
uniform random jittered
Source: Physically Based Rendering, Pharr & Humphreys
![Page 19: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/19.jpg)
Different sampling strategies 19
uniform random jittered
Source: Physically Based Rendering, Pharr & Humphreys
Difference between random and jittered, is that jittered has only 1 sample
within each cell. It’s still randomly perturbed!
![Page 20: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/20.jpg)
Reconstruction filters
once we have samples, must recombine to get
final color
most popular
box
triangle
Gaussian
20
![Page 21: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/21.jpg)
Putting it all together
foreach pixel
for(number_samples)
x, y = getNewSampleLocation(pixel);
camera.makeRay(ray, x, y);
bvh.intersect(hit, ray);
result += shade( ... ); // box filter
result /= number_samples; // box filter
image.set(pixel, result);
21
![Page 22: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/22.jpg)
Global Illumination
so far, we’ve looked at
point lights (no area)
direct illumination (no inter-reflections)
non-physical Phong shading
fake ambient light term
our world behaves a little differently
we have all the tools to get it (mostly) right!
22
![Page 23: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/23.jpg)
Global Illumination
23
![Page 24: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/24.jpg)
Global Illumination
24
![Page 25: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/25.jpg)
Global Illumination
25
![Page 26: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/26.jpg)
Let’s try to derive path tracing
Board time!
Slides online will include this info
26
![Page 27: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/27.jpg)
Path tracing algorithm 27
...
for(number_samples)
attenuation = Color(1.f, 1.f, 1.f);
ray = generateNewRay( ... );
while(depth < max_depth) {
HitRecord hit;
bvh.intersect(hit, ray);
result += shade(…) * attenuation;// box filter
attenuation *= mat_color;
r = hemiRay(…);
depth++
}
result /= number_samples; // box filter
// tone map!
image.set(pixel, result);
![Page 28: CS 6958 LECTURE 13 INTRO TO ANTI-ALIASING, PATHTRACINGcs6958/slides/Lec15.pdf · What is Aliasing? 3 If we render it with our ray tracers… Source: Physically Based Rendering, Pharr](https://reader036.fdocuments.in/reader036/viewer/2022071108/5fe32f8f19bad715a62abe2d/html5/thumbnails/28.jpg)
End
28