SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... ·...
Transcript of SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... ·...
SOME THEORY BEHIND REAL-TIME RENDERING
Jaroslav Křivánek Charles University in Prague
Off-line realistic rendering (not yet in rea-time)
Ray tracing
3
4
5
Image created by Bertrand Benoit Rendered in Corona Renderer
6
Image created by Jeff Patton Rendered in Corona Renderer
ŠKODA Rapid Catalogue 7
8
9
Image created by Weta Digital © 20th Century Fox
10
Image created by Weta Digital © 20th Century Fox
vimeo >> “The Great Gatsby VFX” 11
vimeo >> “The Great Gatsby VFX” 12
Global illumination
Global illumination – Color bleeding
Image credit: Michael Bunnell 14 14
Global illumination – Caustics
15
Global illumination in games
16
Basic light transport theory
Image generation
Pixel value = average radiance reflected from surfaces visible through the pixel
Generating an image involves (some sort of) light transport simulation
18
Radiance L (x, ω)
18
Radiance
Radiometric quantity measuring “amount of light energy” along a ray
Denoted L (x, ω) x … position ω … direction
Units [W / m2 sr ]
Essential properties of radiance
Proportional to perceived brightness xxxxx
Constant along a ray xxxxxx
x
ω
19
Light reflection
x 20 20
Light reflection
BRDF
Bi-directional Reflectance Distribution Function
Obr. Wojciech Matusik
21 21
Bidirectional Reflectance Distribution Function
dωi Lr(ωo)
θo
n Li(ωi)
θi
]sr[dcos)(
)(d)( 1
iiii
oroi
−
⋅⋅=→
ωθωωωω
LLfr
BRDF – Formal definition
„incoming“
„outgoing“
„reflected“
22
Surface appearance and the BRDF
23
Appearance BRDF lobe (for four different viewing directions)
Souce: Ngan et al. Experimental analysis of BRDF models, http://people.csail.mit.edu/addy/research/brdf/
Surface appearance and the BRDF
24
Appearance BRDF lobe (for four different viewing directions)
Souce: Ngan et al. Experimental analysis of BRDF models, http://people.csail.mit.edu/addy/research/brdf/
Surface appearance and the BRDF
25
Appearance BRDF lobe (for four different viewing directions)
Souce: Ngan et al. Experimental analysis of BRDF models, http://people.csail.mit.edu/addy/research/brdf/
Surface appearance and the BRDF
26
Appearance BRDF lobe (for four different viewing directions)
Souce: Ngan et al. Experimental analysis of BRDF models, http://people.csail.mit.edu/addy/research/brdf/
Reflection equation
Total reflected radiance: integrate contributions of incident radiance, weighted by the BRDF, over the hemisphere
∫ ⋅→⋅=)(
iioiiior dcos),(),(),(x
xxxH
rfLL ωθωωωω
dωi θo
n Li(x, ωi)
θi Lr(x, ωo)
upper hemisphere over x
CG III (NPGR010) - J. Křivánek 2015
But where does the incident radiance come from? Other surfaces in the scene!
Rendering Equation
x
L(r(x,ωi), −ωi)
28
ωi
ωo Li(x,ωi)
28
∫ ⋅→⋅−+
=
)(iioiiio
oeoo
dcos),()),,(r(
),(),(
x
xx
xx
HrfL
LL
ωθωωωω
ωω
Recursive calculation of rendering equation
To calculate L(x, ωo) I need to calculate L(r(x, ω’), −ω’)
for all directions ω’ around the point x. For the calculation of each L(r(x, ω’), −ω’) I need to do
the same thing recursively At each step, apply Monte Carlo integration to sample
the hemisphere etc.
x
ω’ r(x, ω’)
ω’’
ωo
r( r(x,ω’), ω’)
29
Monte Carlo integration
General approach to numerical evaluation of integrals
x1
f(x)
0 1
p(x)
x2 x3 x4 x5 x6
Integral:
Monte Carlo estimate of I:
Correct „on average“:
30
Slide credit: Iwan Kawrakov
31
L: Equilibrium radiance Le: Emitted radiance T: Transport & scattering operator
LTLL += e
Rendering equation – Operator form
LTLL += e
32
Progressive approximation
Each application of T corresponds to one step of reflection & light propagation
...e3
e2
ee ++++= LTLTTLLL
emission
direct illumination
one-bounce indirect illumination
two-bounce indirect illumination
OpenGL shading 33
Progressive approximation
eL
eL
eLT eLTT eLTTT
ee LTL + e2
ee LTTLL ++ e3
e ... LTL ++
34
Idea: Distributed ray tracing (Cook ‘84)
35
Path tracing
36
Path tracing, Naive
getLi (x, ω): y = traceRay(x, ω) return Le(y, –ω) + // emitted radiance Lr (y, –ω) // reflected radiance Lr(y, ω): ω′ = genUniformRandomDir( n(y) ) return getLi (y, ω′) * brdf(y, ω, ω′) * dot(ω′, n(y)) * 2π
37
Path tracing, Naive
getLi (x, ω): y = traceRay(x, ω) return Le(y, –ω) + // emitted radiance Lr (y, –ω) // reflected radiance Lr(y, ω): ω′ = genUniformRandomDir( n(y) ) return getLi (y, ω′) * brdf(y, ω, ω′) * dot(ω′, n(y)) * 2π
38
Practical formulas for light transport
P. Dutré: Global Illumination Compendium, http://people.cs.kuleuven.be/~philip.dutre/GI/
39
ROBUST GI CALCULATION
Path sampling techniques
Path tracing Light tracing Bidirectional path tracing
41
All possible bidirectional techniques vertex on a light sub-path vertex on en eye subpath
42
All possible bidirectional techniques vertex on a light sub-path vertex on en eye subpath
VPLs
no single techniques importance samples all the terms
43
Bidirectional path tracing
Use all of the above sampling techniques
Combine using Multiple Importance Sampling
44
BPT Implementation
45
Results
BPT, 25 samples per pixel PT, 56 samples per pixel
Imag
es: E
ric
Vea
ch
46
Insufficient path sampling techniques
Reference solution Bidirectional path tracing 47
Insufficient path sampling techniques
In BPT, Specular-Diffuse-Specular paths sampled with zero (or very small) probability
diffuse – D
specular – S
48
PHOTON MAPPING
(DENSITY ESTIMATION)
Photon mapping (Density estimation)
1. Many fwd walks + store collisions (“photon map”) 2. Radiance estimate: (Kernel) density estimation
50
Photon mapping
1. Photon tracing „Photon“ emission Particle tracing Storage in the „photon map“
2. Rendering with photon map Like path tracing Photon map query instead
of recursion
51
Photon mapping – SDS paths
© Wojciech Jarosz
© H.W.Jensen
52
Our work: Vertex Connection and Merging BPT + PM combination
Bidirectional path tracing (30 min) 54
Photon mapping (Density estimation) (30 min) 55
Vertex connection and merging (30 min) 56
THANK YOU!
Questions?
[cgg.mff.cuni.cz/~jaroslav]