cs380: introduction to computer graphics light transport...
TRANSCRIPT
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
CS380: Introduction to Computer GraphicsLight Transport
Chapter 21
Min H. KimKAIST School of Computing
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
SUMMARYColor and Ray-Tracing
2
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Ray tracing
3
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Ray-plane• Plane described by the equation• We start by representing every point along the
ray using a single parameter λ
• Plugging this into the plane equation, we get
4
Ax+By+Cz+D=0
xyz
⎡
⎣
⎢⎢⎢
⎤
⎦
⎥⎥⎥=
pxpypz
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
+ λdxdydz
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
0 = A(px + λdx )+ B(py + λdy )+C(pz + λdz )+ D = λ(Adx + Bdy +Cdz )+ (Apx + Bpy +Cpz + D)
pd
Eye origin Pixel ray vector
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Ray-triangle• Suppose we wish to test if a point is inside or
outside of a triangle in 2D • Consider the three “sub” triangle
• When is inside of , then all three sub-triangles will agree on their clockwisedness. When is outside, then they all disagree.
5
q
Δ( p1 p2 p3)
Δ( p1 p2 q),Δ( p1 qp3)
and Δ( qp2 p3)
q Δ( p1 p2 p3)
q
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Ray-sphere• Suppose we have a sphere with radius R and
center c modeled as the set of points that satisfy the equation
• Plugging the below into the above:
• We get
6
[x, y, z]t
(x − cx )2 + (y − cy )
2 + (z − cz )2 − r2 = 0
xyz
⎡
⎣
⎢⎢⎢
⎤
⎦
⎥⎥⎥=
pxpypz
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
+ λdxdydz
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
0 = (px + λdx − cx )2 + (py + λdy − cy )
2 + (pz + λdz − cz )2 − r2
0 = (dx2 + dy
2 + dz2 )λ 2 + (2dx (px − cx )+ 2dy(py − cy )+ 2dz (pz − cz ))λ +
(px − cx )2 + (py − cy )
2 + (pz − cz )2 − r2
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Three sources of light together
7Courtesy of Doug A. Bowman
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Bounding volume hierarchy (BVH)
8
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
LIGHT TRANSPORTChapter 21
9
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
RENDERING EQUATIONHemispherical formulation
10
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Solid angle• Steradian (sr)– The solid angle subtended at the center of a sphere
by an area on its surface numerically equal to the square of the radius.
11
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Solid angle• 2D vs. 3D angle
12
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Solid angle• A measure on the hemisphere to integrate functions over the
hemisphere [unit: steradian (sr)]
• A finite solid angle subtended by an area on the hemisphere is defined as the total area divided by the squared radius of the hemisphere:
• The area of the hemisphereis:
13
Ω
Ω = Ar2
2πr2
1 steradian ⇔ A = r2
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Solid angle• The solid angle area covered by a complete hemisphere
equals:• The solid angle covered by a complete sphere equals:• Note that the solid angle is not dependent on the
shape of surface ,but is only dependent on the total area .
14
2π
4π
A
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Solid angle• We can project the surface or object on the
hemisphere and compute the solid angle of the projection.
• The two objects different in shape can still subtend the same sold angle.
15
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiant power• A bunch of photons flying through space in a
direction.• Radiant power: Each photon carries energy
[unit: joules]
16
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiant flux• Radiant flux: radiant power measured in
seconds, measured in watts [joules/sec]• Radiant flux does not specify the size of the light
source or receiver.• Flux does not include a specification of the
distance between the light source and the receivers.
17
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiant flux• A bunch of photons flying through
space in a direction.• We have a sensor (W, X) out in
space– W is a wedge of directions– Pass through the surface X
• Each photon carries energy in units of joules
• Radiant flux: energy measured in seconds, measured in watts:
18
Φ(W ,X)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiant power vs. distance• d2 law
19
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Irradiance• Irradiance: Measured radiant flux by the area of
the sensor (measured in square meters)
• Smaller and smaller X around a single point(under continuity assumptions about )à irradiance
• Note E at a different normal is different
20
E(W ,X) := Φ(W ,X)X
xΦ
En (W , x)
!ʹn
E !n(W , "x)≠E !ʹn (W , "x)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Irradiance• Suppose the sensor surface X broken up into a bunch of
smaller surfaces, Xi.• Radiant flux over the entire sensor as the sum:
• Under reasonable continuity assumption about , radiance flux from pointwise (pixelwise) irradiance:
21
Φ(W ,X )= Φ(W ,Xi )=
i∑ Xi E(W ,Xi )
i∑
Φ
Φ(W ,X )= E !n( "x )X∫ (W , "x)dA
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiosity (radiant exitance)• Exitant radiant power per unit surface area [unit:
W/sqm]
• E.g., consider a light source, of area 0.1 sqm, that emits 100 watts. à The radiant exitance of the light is 1,000 W/sqm at each point of its source.
22
M = B = dΦdA
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiance• In , shrink W down to a single vector,
dividing out by |W|, the solid angle measure of W (unit: steradians) à radiance
23
En (W , x)
L!n(W , "x)=
E !n(W , "x)W
(the wedge of all directioncovers 4π steradians)
L!n(!w , "x)= lim
W→ !wL!n(W , "x)
L!n(!w , "x): L( !w , "x)withgiven
surfaceorientation!n
L(!w , "x):=L
−!w(!w , "x)
L−!w(!w , "x)= 1cos(θ )L!n(
!w , "x)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiance• Smaller and smaller wedges around a vector
pointing toward • Under reasonable continuity assumption for
radiance:unit:
24
L( !w , "x):=L
−!w(!w , "x)= L!n(
!w , "x)cos(θ )
!w
x
Φis the angle
between and n −
wθ
Watt / (sr ⋅m2 ⋅nm)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Incoming radiance• Incoming radiance:
• Given a spatially and angularly varyingwe can compute the radiant flux over a large sensor (W,X) as:
25
L( !w, "x) := 1
cos(θ )limW→ !w
1W
limX→ "x
Φ(W ,X)X
⎛⎝⎜
⎞⎠⎟
L(w, x)
Φ(W ,X )= L(!w , "x)cos(θ )dw
W∫( )dAX∫
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Outgoing radiance• In fact, radiance remains constant along a ray in
free space:• We can define outgoing radiance from
the point in the direction . • Reverse the order of the arguments to L
• where is the radiant flux of photons leaving a finite surface X along vectors in the wedge W
26
L(!w, "x) = L( !w, "x + !w)
L( x,w)
x w
L( !x, "w) := 1
cos(θ )limW→ "w
1W
limX→ !x
Φ(X,W )X
⎛⎝⎜
⎞⎠⎟
Φ(X,W )
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiance in computer graphics• We calculate the color of some 3D point in an
OpenGL fragment shader as the outgoing radiance , where is the “view vector”.
• In the fragment shader, this outgoing radiance value is also the incoming radiance value at the corresponding sample location on the image plane and is thus used to color the pixel.
• In ray tracing, when we trace a ray along the ray, we can interpret this as calculating the
incoming radiance value, .27
!x
L( x,v)
v
( x,d )
L(−d, x)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiant flux along a ray• Slide our sensor (W,X) along the vector to
obtain the shifted sensor (W,X’), where
• Radiant fluxes will not agree (due to the d2 law)
28
w
X ' = X +w
Φ(W ,X) ≠ Φ(W , ′X )
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Radiance along a ray• Radiance will agree
29
L( !w, "x) := 1cos(θ )
limW→ !w
1W
limX→ "x
Φ(W ,X)X
⎛⎝⎜
⎞⎠⎟
= 1cos(θ )
limX→ "x
1X
limW→ !w
Φ(W ,X)W
⎛⎝⎜
⎞⎠⎟
= 1cos(θ )
limX→ "x
1X
limW→ !w
Φ(W ,X + !w)W
⎛⎝⎜
⎞⎠⎟
= 1cos(θ )
lim′X → "x+ !w
1′X
limW→ !w
Φ(W , ′X )W
⎛⎝⎜
⎞⎠⎟
= 1cos(θ )
limW→ !w
1W
lim′X → "x+ !w
Φ(W , ′X )′X
⎛⎝⎜
⎞⎠⎟= L( !w, "x + !w)
∵ lim
W→ "w
Φ(W , ʹX )Φ(W ,X ) =1 → X '≈ X +
"w⎛
⎝⎜
⎞
⎠⎟
In fact, in the limit for very small wedges, our senor and shifted sensor measure the same set of photons.
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Reflection• Bidirectional reflectance distribution function (BRDF) is
the reflection ratio that converges and does not actually depend on the size of the wedges.
• Making the incoming wedges W smaller around a fixed , this function f converges to
• The simplest BRDF is the constant BRDF (for diffuse material):
30
f !x ,"n(W ,
"v)= L1( !x , "v)
E "ne(W , !x)
= L1( !x , "v)
L"ne (W , !x)W
!w f !x ,"n(
"w , "v)
f !x ,"n("w , "v)=1
f !x ,"n("w , "v)= lim
W→ "w L
1( !x , "v)L"ne (W , !x)W
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Reflection• On a diffuse surface, the amount of scattered
photons drops by a cosine factor to zero, while the outgoing radiance does not depend on outgoing angle in the BRDF definition. (don’t get confused with the viewing direction.)
• Outgoing radiance is• Using ,
the reflected radiance is
31
L1( !x , "v)= Wi f !x ,"n(Wi ,
"v)L"ne (Wi , !x)i∑
f x,n (w, v) and Ln
e ( w, x)
L1( !x , "v)= f !x ,"n("w , "v)L"ne (
"w , !x)dwH∫
= f !x ,"n("w , "v)Le( "w , !x)cosθdw
H∫
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Mirror reflection• In a mirror surface, the bounced
radiance along a ray, depends only on where
• Mirror reflection: where is some material coefficient.
• Mirror reflected light is
• Note that no integration is required in perfect mirror reflection.
32
Le −B(v), x[ ]
B(v) = 2(v ⋅ n)n − v
k x,n (v) = L
1( x, v)Le[−B(v), x]
k x,n (v)
L1( x, v) = k x,n (
v)Le[−B(v), x]
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Rendering Equation• Reflection equation in shorthand
where B is the bounce operator of light.• Recursive light transport is• We can say
33
L1 =BLe
Li+1 = BLi
Lt =Le +L1+L2+L3+ ... =Le +B(Le +L1+L2+L3+ ...) =Le +BLt
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Rendering Equation• The rendering equation (integral equation) is
34
Lt( !x , "v)=Le( !x , "v)+ f !x ,"n("w , "v)Lt( "w , !x)cos(θ )dw
H∫Lt( !x , "v):receivedlightLe( !x , "v): emittinglightf !x ,"n("w , "v):reflectancefunction
Lt( "w , !x): incidentlightcos(θ ): thecosinelawH : theentire(hemi-)sphericalsolidangledw:differentialsolidangle
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Global Illumination (2nd bounce)
where is the point first hit along the ray
35
Le : light source emissionL1 : the first bounceL2 : the second bounceLn : the nth bounce
L2( !x , "v)= f !x ,"n("w , "v)cos(θ )L1( "w , "x)dw
H∫= f !x ,"n(
"w , "v)cos(θ ) f !ʹx ,"ʹn ("ʹw , "w)cos( ʹθ )Le( " ʹw , "ʹx )d ʹw
ʹH∫( )dwH∫= f !x ,"n(
"w , "v)cos(θ ) f !ʹx ,"ʹn ("ʹw , "w)cos( ʹθ )Le( " ʹw , "ʹx )d ʹw
ʹH∫ dwH∫
ʹ!x ( !x,−"w)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Path tracing• Adding one more bounce• Geometric path of light transport:• Not as a nested integral over two hemispheres,
but as an integral over an appropriate space of pathsà Path tracing
36
Le( !x , "v)+L1( !x , "v)+L2( !x , "v)
( !x , !ʹx , ! ʹ́x )
light
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
• is less important than direct lighting.• It is needed to simulate blurry reflections of the
surrounding environment• Caustic effects can also be seen due to• Total light:• (higher bounces account for the overall distributions of
light and darkness in the environment)
Path tracing
37
L2
L2
Lt = Le + L1 + L2 + L3 + ...
Caustic effects
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Path tracing• Reflection equation in shorthand
where B is the bounce operator of light.• Recursive light transport is• We can say
• This expresses an equation that must hold for the total equilibrium distribution .
38
L1 =BLe
Li+1 =BLi
Lt =Le +L1+L2+L3+ ...Lt =Le +B(Le +L1+L2+L3+ ...)Lt =Le +BLt
Lt( !x , "v)=Le( !x , "v)+ f !x ,"n(
"w , "v)Lt( "w , !x)cos(θ )dwH∫
Lt
(∵L1 =BLe )
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Camera Sensor• Photon count at pixel (i,j) in a physical camera
model:
where T is the duration of the shutter, Ωi,j is the spatial support of pixel (i,j)at the sensor pointand W is the wedge of the incoming vectorfrom the aperture toward the film point.
39
dt dA dwFi , j( !x)Lt(
"w , !x)cos(θ )W∫Ωi , j∫T∫
x
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Sensor• Other effects– Motion blur: due to integration over the shutter
time– Depth of field: due to integration over the solid
angle of the aperture(focus and blur effects)
40
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Sensor• Motion blur & Depth-of-field effect
• Subsurface scattering
41
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
REFLECTION EQUATION (SUMMARY)
42
BRDF
n
o
df
h
hq
dq
i
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Lt( !x , "v)=Le( !x , "v)+ f !x ,"n("w , "v;m,η)Lt( "w , !x)cos(θ )dw
H∫
Lt( !x , "v):receivedlightLe( !x , "v): emittinglightf !x ,"n("w , "v):reflectancefunction
Lt( "w , !x): incidentlightcos(θ ): thecosinelawH : theentire(hemi-)sphericalsolidangledw:differentialsolidangle
!n
!w
df
!h
hq
dq
!w
Rendering Equation
43
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Microfacet-based Reflectance Model
44
Lt( !x , "v)=Le( !x , "v)+ f !x ,"n("w , "v;m,η)Lt( "w , !x)cos(θ )dw
H∫f !x ,"n("w , "v;η)=kd f !xdiffuse +ks f !x ,"nspecular , wherekd +ks =1
f !xdiffuse:diffusetermf !x ,"nspecular( "w , "v;m,η): specularterm
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Diffuse Reflection
• Diffuse reflection– Internal scattering– Multiple reflection within microfacets
• It is a constant per material
45
f !x ,"ndiffuse( "w , "v)= ρ
π,
whereρ:diffusealbedo
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Specular Reflection (D)-1
46
f !x ,"nspecular( "w , "v;m,η)= D(
"h;m)G( "w , "v ,
"h)F( "w ,
"h;η)
4("n ⋅ "w)("n ⋅ "v)D : Microfacetnormaldistributionfunction(probabilitydensityfunction),1= D(
"h)("h ⋅ "n)dwhH∫
Multiplespecularlobes: D= wjD(mj )j∑ , wj
j∑ =1
(1)Beckmanndistribution[Cook1982]:
D θh;m( ) =exp(−tan2(θh)/m2)
πm2cos4θh,
θh = cos−1(!h ⋅ !n),m:roughnessparameter
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Specular Reflection (D)-2
47
(2)GGXdistribution[Walter2007]:
D(θh;m)=m2
π cos4θh m2+ tan2θh( )2 ,
θh = cos−1(!h ⋅ !n),m:roughnessparameter
f !x ,"nspecular( "w , "v;m,η)= D(
"h;m)G( "w , "v ,
"h)F( "w ,
"h;η)
4("n ⋅ "w)("n ⋅ "v)D : Microfacetnormaldistributionfunction(probabilitydensityfunction),1= D(
"h)("h ⋅ "n)dwhH∫
Multiplespecularlobes: D= wjD(mj )j∑ , wj
j∑ =1
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Specular Reflection (D)-3
48
With a roughness of 0.5
https://mynameismjp.wordpress.com/2016/10/09/sg-series-part-4-specular-lighting-from-an-sg-light-source/
With a roughness of 0.25
• Facet distribution
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Specular Reflection (G)-1
49
(1)V-groovecavitymodel[Cook1982]:
Gshadowing(!w ,!h)=min 1,2|
!h ⋅ !n|| !w ⋅ !n|| !w ⋅!h|
⎛
⎝⎜
⎞
⎠⎟,
Gmasking(!v ,!h)=min 1,2|
!h ⋅ !n|| !v ⋅ !n|| !v ⋅!h|
⎛
⎝⎜
⎞
⎠⎟,
G( !w , !v ,!h)=min Gshadowing(
!w ,!h),Gmasking(
!v ,!h)( ).
f !x ,"nspecular( "w , "v;m,η)= D(
"h;m)G( "w , "v ,
"h)F( "w ,
"h;η)
4("n ⋅ "w)("n ⋅ "v)G : Geometricattenuationfunction(shadowing/masking)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
Specular Reflection (G)-2
50
(2)SmithGmodel[Heitz2014]:
G( !w , !v;m)= 21+ 1+m2 tan2 !w⎛
⎝⎜⎜
⎞
⎠⎟⎟
21+ 1+m2 tan2 !v⎛
⎝⎜⎜
⎞
⎠⎟⎟
m:roughnessparameter
f !x ,"nspecular( "w , "v;m,η)= D(
"h;m)G( "w , "v ,
"h)F( "w ,
"h;η)
4("n ⋅ "w)("n ⋅ "v)G : Geometricattenuationfunction(shadowing/masking)
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
!n = !w= !v (0)F
Specular Reflection (F)
51
(1)Schlickapproximation:F(!h, !w;η)=F(0;η)+(1−cosθh)5(1−F(0;η))
θh = cos−1!h ⋅ !w( )
F(0;η): Fresnelcolordependsontherefractiveindexη ofeachmaterial
f !x ,"nspecular( "w , "v;m,η)= D(
"h;m)G( "w , "v ,
"h)F( "w ,
"h;η)
4("n ⋅ "w)("n ⋅ "v)F : Fresnelpolarizationeffect
(0) 0.5F =
-
Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012
CS580: Computer Graphics• If you want to learn more about advanced
rendering for global illumination, there is a course (CS580) delivered by Prof. Kim.
• http://vclab.kaist.ac.kr/cs580
52
http://vclab.kaist.ac.kr/cs580