57
SOME THEORY BEHIND REAL-TIME RENDERING Jaroslav Křivánek Charles University in Prague

SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

SOME THEORY BEHIND REAL-TIME RENDERING

Jaroslav Křivánek Charles University in Prague

Page 2: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Off-line realistic rendering (not yet in rea-time)

Page 3: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Ray tracing

3

Page 4: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

4

Page 5: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

5

Image created by Bertrand Benoit Rendered in Corona Renderer

Page 6: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

6

Image created by Jeff Patton Rendered in Corona Renderer

Page 7: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

ŠKODA Rapid Catalogue 7

Page 8: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

8

Page 9: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

9

Image created by Weta Digital © 20th Century Fox

Page 10: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

10

Image created by Weta Digital © 20th Century Fox

Page 11: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

vimeo >> “The Great Gatsby VFX” 11

Page 12: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

vimeo >> “The Great Gatsby VFX” 12

Page 13: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Global illumination

Page 14: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Global illumination – Color bleeding

Image credit: Michael Bunnell 14 14

Page 15: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Global illumination – Caustics

15

Page 16: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Global illumination in games

16

Page 17: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Basic light transport theory

Page 18: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 19: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 20: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Light reflection

x 20 20

Page 21: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Light reflection

BRDF

Bi-directional Reflectance Distribution Function

Obr. Wojciech Matusik

21 21

Page 22: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 23: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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/

Page 24: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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/

Page 25: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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/

Page 26: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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/

Page 27: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 28: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

ωθωωωω

ωω

Page 29: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 30: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 31: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Slide credit: Iwan Kawrakov

31

Page 32: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

L: Equilibrium radiance Le: Emitted radiance T: Transport & scattering operator

LTLL += e

Rendering equation – Operator form

LTLL += e

32

Page 33: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 34: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Progressive approximation

eL

eL

eLT eLTT eLTTT

ee LTL + e2

ee LTTLL ++ e3

e ... LTL ++

34

Page 35: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Idea: Distributed ray tracing (Cook ‘84)

35

Page 36: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Path tracing

36

Page 37: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 38: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 39: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Practical formulas for light transport

P. Dutré: Global Illumination Compendium, http://people.cs.kuleuven.be/~philip.dutre/GI/

39

Page 40: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

ROBUST GI CALCULATION

Page 41: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Path sampling techniques

Path tracing Light tracing Bidirectional path tracing

41

Page 42: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

All possible bidirectional techniques vertex on a light sub-path vertex on en eye subpath

42

Page 43: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 44: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Bidirectional path tracing

Use all of the above sampling techniques

Combine using Multiple Importance Sampling

44

Page 45: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

BPT Implementation

45

Page 46: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Results

BPT, 25 samples per pixel PT, 56 samples per pixel

Imag

es: E

ric

Vea

ch

46

Page 47: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Insufficient path sampling techniques

Reference solution Bidirectional path tracing 47

Page 48: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Insufficient path sampling techniques

In BPT, Specular-Diffuse-Specular paths sampled with zero (or very small) probability

diffuse – D

specular – S

48

Page 49: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

PHOTON MAPPING

(DENSITY ESTIMATION)

Page 50: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Photon mapping (Density estimation)

1. Many fwd walks + store collisions (“photon map”) 2. Radiance estimate: (Kernel) density estimation

50

Page 51: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

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

Page 52: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Photon mapping – SDS paths

© Wojciech Jarosz

© H.W.Jensen

52

Page 53: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Our work: Vertex Connection and Merging BPT + PM combination

Page 54: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Bidirectional path tracing (30 min) 54

Page 55: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Photon mapping (Density estimation) (30 min) 55

Page 56: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

Vertex connection and merging (30 min) 56

Page 57: SOME THEORY BEHIND REAL-TIME RENDERINGartemis.ms.mff.cuni.cz/gemrot/...graphics_for_games... · vimeo >> “The Great Gatsby12 VFX ” Global illumination . ... Global illumination

THANK YOU!

Questions?

[cgg.mff.cuni.cz/~jaroslav]