cs 6958 lecture 13 intro to anti-aliasing, pathtracingcs6958/slides/lec15.pdf · what is aliasing?...

Post on 01-Sep-2020

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CS 6958

LECTURE 13

INTRO TO ANTI-ALIASING,

PATHTRACING

March 3, 2014

What is Aliasing? 2

Imagine this is our scene

Source: Physically Based Rendering, Pharr & Humphreys

What is Aliasing? 3

If we render it with our ray tracers…

Source: Physically Based Rendering, Pharr & Humphreys

What is Aliasing? 4

If we render it with our ray tracers…

Source: Physically Based Rendering, Pharr & Humphreys

What is Aliasing? 5

Consider our Cornell Box

What is Aliasing? 6

Consider our Cornell Box

What is Aliasing? 7

Consider our Cornell Box

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

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

Consider a 2x2 image 10

-1 0 1

0

1

Pixel

Pixel centers 11

-1 0 1

0

1

(-0.5, -0.5) (-0.5, 0.5)

(-0.5, 0.5) (0.5, 0.5)

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)

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)

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

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

Different sampling strategies 16

uniform

Source: Physically Based Rendering, Pharr & Humphreys

Different sampling strategies 17

uniform random

Source: Physically Based Rendering, Pharr & Humphreys

Different sampling strategies 18

uniform random jittered

Source: Physically Based Rendering, Pharr & Humphreys

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!

Reconstruction filters

once we have samples, must recombine to get

final color

most popular

box

triangle

Gaussian

20

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

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

Global Illumination

23

Global Illumination

24

Global Illumination

25

Let’s try to derive path tracing

Board time!

Slides online will include this info

26

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);

End

28

top related