cs 6958 lecture 16 pathtracing review, materialscs6958/slides/lec17.pdf · path tracing...
TRANSCRIPT
![Page 1: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/1.jpg)
CS 6958
LECTURE 16
PATHTRACING REVIEW,
MATERIALS
March 3, 2014
![Page 2: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/2.jpg)
Recall 2
can split illumination into direct and indirect
direct
indirect
![Page 3: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/3.jpg)
Recall 3
surfaces respond to this illumination
direct
indirect
![Page 4: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/4.jpg)
Recall 4
in reality, both direct and indirect light comes
from many directions
direct indirect
![Page 5: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/5.jpg)
Recall 5
… and surface response can vary drastically
based on material!
smooth diffuse
Source: Mitusba 0.5 documentation, https://www.mitsuba-renderer.org/docs.html
![Page 6: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/6.jpg)
Recall 6
… and surface response can vary drastically
based on material!
smooth diffuse smooth dielectric smooth conducting scattering
rough diffuse rough dielectric rough conducting
Source: Mitusba 0.5 documentation, https://www.mitsuba-renderer.org/docs.html
![Page 7: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/7.jpg)
Recall – path tracing 7
Step 1. shoot ray from eye
ray attenuation = (1, 1, 1)
primary ray
![Page 8: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/8.jpg)
Recall – path tracing 8
Step 2. accumulate direct contributions
keep track of material response per light
shadow ray
![Page 9: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/9.jpg)
Recall – path tracing 9
Step 3. scale ray attenuation by material
estimate indirect illumination by shooting a ray
next bounce
![Page 10: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/10.jpg)
Recall – path tracing 10
Step 4. for new hit point, repeat
![Page 11: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/11.jpg)
Path tracing algorithm 11
...
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;
ray = hemiRay(…);
depth++
}
result /= number_samples; // box filter
// tone map!
image.set(pixel, result);
![Page 12: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/12.jpg)
Path tracing considerations 12
shoot many rays per pixel
samples pixel area = anti-aliasing
(effectively) samples material, (area) lights,
indirect illumination = less noise in image
stopping
max depth reached (5-6 good, scene-dependent)
when attenuation below threshold
must be careful about brightest light value
selecting new shooting direction
based on material
![Page 13: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/13.jpg)
Lambertian material
𝐿𝑅𝑒𝑓𝑙𝑒𝑐𝑡𝑒𝑑 = 𝐶𝐿𝑖𝑔ℎ𝑡 ∙ 𝐶𝑚𝑎𝑡𝑒𝑟𝑖𝑎𝑙 ∙ cos 𝜃
cos 𝜃 = 𝑁 ∙ 𝐿, after normalization
13
N
L
![Page 14: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/14.jpg)
Dielectric material
Ex: glass, water, diamond, etc
Incoming energy is split into Reflected and
Transmitted
angular dependence based on indices of
refraction – Snell’s law
14
N
R I
T
![Page 15: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/15.jpg)
Snell’s Law 15
speed of light is different in different media
light is an EM wave, different component will have different speed
result: the light bends at the interface
sin 𝜃1sin 𝜃2
=𝑣1𝑣2
=𝑛2𝑛1
Source: Wikipedia, http://en.wikipedia.org/wiki/Snell%27s_law
![Page 16: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/16.jpg)
Snell’s Law 16
Total internal reflection
gives diamonds their shine
occurs beyond critical angle
Source: Wikipedia, http://en.wikipedia.org/wiki/Snell%27s_law
𝜃𝑐 = sin−1𝑛2𝑛1
sin 𝜃2 = sin−1𝑛2𝑛1
![Page 17: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/17.jpg)
Examples of coefficients
Material Index of refraction
Vacuum 1.0
Water 1.3330
Acetone 1.36
Ethanol 1.361
Silicone Oil 1.52045
Water Ice 1.31
Fused Quartz 1.458
Pyrex 1.470
Acrylic Glass 1.49
Amber 1.55
Diamond 2.419
17
Source: Mitusba 0.5 documentation, https://www.mitsuba-renderer.org/docs.html
![Page 18: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/18.jpg)
Fresnel Coefficients 18
power is reduced based on reflected and
transmitted angles
Source: Wikipedia, http://en.wikipedia.org/wiki/Fresnel_equations
![Page 19: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/19.jpg)
Fresnel Coefficients 19
power is reduced based on reflected and
transmitted angles
use Schlick's approximation (reflected amount)
transmitted is then 𝑇 𝜃 = 1 − 𝑅 𝜃
Source: Wikipedia, http://en.wikipedia.org/wiki/Fresnel_equations
𝑅 𝜃 = 𝑅0 + 1 − 𝑅0 1 − cos 𝜃 5
𝑅0 =𝑛1 − 𝑛2𝑛1 + 𝑛2
2
cos 𝜃 =𝐻 ∙ 𝑉
𝐻 – half vector between incident light and view direction 𝑉
![Page 20: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/20.jpg)
Dielectric Pseudocode 20
result = normal lambertian (or other) shading
Ray rray = reflect_ray( ray, … );
if( tir(ray) ) {
// kr = 1, kt = 0
result += traceRay( rray, depth + 1, … );
} else {
// kr = R(theta) using Schlick’s approximation
// kt = 1 - kr
result += kr*traceRay( rray, depth + 1, … );
Ray tray = transmit_ray( ray, … );
result += kt*traceRay( tray, depth + 1, … );
}
![Page 21: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/21.jpg)
Dielectric Pseudocode 21
result = normal lambertian (or other) shading
Ray rray = reflect_ray( ray, … );
if( tir(ray) ) {
// kr = 1, kt = 0
result += traceRay( rray, depth + 1, … );
} else {
// kr = R(theta) using Schlick’s approximation
// kt = 1 - kr
result += kr*traceRay( rray, depth + 1, … );
Ray tray = transmit_ray( ray, … );
result += kt*traceRay( tray, depth + 1, … );
}
See supplemental slides for
derivation of reflected and
transmitted rays using Snell’s Law
![Page 22: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/22.jpg)
Dielectric Pseudocode 22
bool tir( const Ray& ray ) {
float cosTheta = -ray.direction() * normal;
float eta;
if( cosTheta > 0 ) {
// ior_* - index of refraction, aka n
eta = ior_from / ior_to;
} else {
eta = ior_to / ior_from;
}
return ( (1.f - (1.f - cosTheta*cosTheta) /
(eta*eta)) < 0.f );
}
![Page 23: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/23.jpg)
Dielectric Pseudocode 23
bool transmit_ray( const Ray& ray, … ) {
// compute eta and cosTheta the same as in tir
// if cosTheta < 0: flip normal, eta, cosTheta
tmp = 1.f - (1.f - cosTheta1*cosTheta1)/(eta*eta);
cosTheta2 = sqrt(tmp);
Ray tray( hit_point, ray.direction() /
(cosTheta2 - cosTheta1/eta)*normal;
return tray;
}
![Page 24: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/24.jpg)
Dielectric Notes 24
there are more efficient ways of doing it than
the above pseudocode
should probably use a stack of indices
nested refraction
eye starts within media
directions of the normal matter!
Source: Wikipedia, http://en.wikipedia.org/wiki/Snell%27s_law
![Page 25: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/25.jpg)
Famous Material Models 25
surfaces:
Lambertian
Cook-Torrence
Anisotropic Ward
Other microfacet Distributions
Ashikhmin-Shirley, 2000
Walter et. al, 2007
Source: Wikipedia, http://en.wikipedia.org/wiki/Fresnel_equations
![Page 26: CS 6958 LECTURE 16 PATHTRACING REVIEW, MATERIALScs6958/slides/Lec17.pdf · Path tracing considerations 12 shoot many rays per pixel samples pixel area = anti-aliasing (effectively)](https://reader036.vdocument.in/reader036/viewer/2022062606/5fe32e9ce91cd32088111069/html5/thumbnails/26.jpg)
End 26