Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 ·...

65
Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014 1

Transcript of Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 ·...

Page 1: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Physically based shading

Ats Kurvet

MTAT.03.296 Computer Graphics Seminar

Tartu 2014 1

Page 2: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Why use PBS?

• Consistency - across materials and

lighting conditions.

• Speed - of authoring content (better tools,

less variables, intuitive parameters, easier

troubleshooting).

• Easier to achieve “hyperrealism”

• Cheaper.

2

Page 3: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Examples of PBS in action

3

Page 10: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

PBS needs a strong base

• HDR and Tone mapping

• Anti-aliasing (also accounting for specular)

• Per object motion blur

• Depth of field (if using a realistic camera

model)

• PostFX

• …

10

Page 11: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Physics

11

Page 12: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Optics

• Geometrical/ray optics – Basic reflections

– Basic refractions

• Physical/wave optics – Interference

– Diffraction

– Polarization

• Electromagentic wave optics – Maxwell equations

• Quantum optics – Photons: the atomic principle

– Wave-particle duality

12

Page 15: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Lights interaction with matter

15

Page 16: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Refraction and absorption

• The refractive index – Describes how light

interacts with the medium it is travelling in.

– Spectral quantity

– The complex refractive index:

• The real part describes the affect to the speed and thus angle of deviation.

• The imaginary part describes the amount of absorption and color.

http://www.topwallpaperphoto.com/wp-content/uploads/2013/09/Whiskey-Drink.jpg 16

Page 19: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Emission

• Many different

sources and ways

of generation

• There is a

difference between

white light and

white light

http://www.ni.com/cms/images/devzone/tut/image4_20080109201025.png

19

Page 20: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Reflections on a planar surface

20

Page 24: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Math

24

Page 27: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

?

• BTDF

• BSDF

• BSSRDF

27

Page 29: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Reciprocity & energy conservation

29

Page 30: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Reflectance equation

30

Page 32: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Splitting diffuse and specular in the

real world

• Check out the tutorial at: http://filmicgames.com/archives/233

32

Page 33: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Real world examples

33 http://filmicgames.com/archives/547

Page 34: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Real world examples

34 http://filmicgames.com/archives/547

Page 35: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Real world examples

35 http://filmicgames.com/archives/547

Page 36: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Surface Reflectance (Specular

Term)

36

Page 37: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Microfacet theory

• Microgeometry

• Light only reflected when, h=m, where h is the half angle vector and m is the microgeometry normal.

– But only when the surface point is not shadowed or masked by neighboring geometry.

• http://blog.selfshadow.com/publications/s2013-shading-course/hoffman/s2013_pbs_physics_math_notes.pdf original source: “Real-Time Rendering, 3rd edition"

37

Page 39: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Microfacet BRDF

• D(h) – microgeometry normal distribution function

• G(l, v, h) - the geometry function

• F(l, h) - Fresnel reflectance

• 4(n.l)(n.v) – correction factor for transforms between micogeometry space and the macrosurface

39

Page 40: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Fresnel reflectance

• The Fresnel reflectance function computes

the fraction of light reflected from an

optically flat surface.

• Depends on the incomoing angle of the

light and the index of refraction.

• Spectral quality.

• Values between 0 and 1

40

Page 44: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

The Schlick Approximation to

Fresnel

• For microfacet BRDFs (otherwise replace h with n):

44

Page 45: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Microgeometry normal distribution

function - D(m)

• Describes the amount of microgeometry normals m having the same direction as the surface normal n.

• Values must me greater than 0.

• Scalar.

• Determines the size, brightness, and shape of the specular highlight.

• Isotropic and anisotropic surfaces.

https://lva.cg.tuwien.ac.at/ecg/wiki/lib/exe/fetch.php?hash=ac8b26&media=http%3A%2F%2Fwww.cs.utexas.edu%2F~fussell%2Fcourses%2Fcs384g%2Fprojects%2Fraytracing%2Fray_examples%2Fanisotropy_ball.jpg & http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf

45

Page 47: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Geometry function - G(l, v, m)

• Represents the probability that surface

points with a given microgeometry normal

m will be visible from both the light

direction l and the view direction v.

• Scalar.

• Values between 0 and 1.

47

Page 48: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Limitations of the Microfacet model

• Does not account for pronounced wave optics effects (such as diffraction and interference), those are usually solved with ad hoc methods.

• Geometry features in the scale range of wavelength of light, or larger features becoming smaller due to foreshortening at grazing angles.

• More complex microgeometry.

48

Page 49: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Subsurface Reflectance (Diffuse

Term)

49

Page 50: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Diffuse Term

• Gets the left over light that is not reflected straight off the surface(specular term).

• Spectral.

• Values between 0 and 1.

• Extra considerations to look at:

– Specular reflectance increases at grazing angles so the diffuse value must decrease.

– Affect of roughness (microgeometry features larger than that of the sub-surface scattering distance)

50

Page 51: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Lambert

• Most widely used. A constant value.

51

Page 52: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Other terms

• Subsurface single-scattering.

• Multiple-bounce surface reflectance.

• Might want to account for these in some

ways no.

52

Page 53: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Illumination model

53

Page 54: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

General Lighting

• Integrate BRDF against all incoming light

from all directions.

• Solving this requires global illumination

models such as Monte Carlo ray tracing.

54

Page 55: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Image-Based Lighting

• Typically represented as environment maps, can also be represented by spherical harmonics for example.

• Works well for smooth surfaces, needs to be sampled for arbitrary BRDFs.

• Perceptually flexible.

55 http://www.randomcontrol.com/images/products/arion2/importance_sampling.gif

Page 56: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Area Lights

• Have both intensity and area

• In reality all light sources have

dimensions, this avoids issues like

specular intensity reaching inifinity.

• Faster shadow calculations than

environment maps.

• Physically more correct.

56

Page 58: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Punctual Light Sources

• Infinitely small, infinitely bright, physically not correct.

• Computationally convenient.

• Effects are defined by:

– Clight - intenisty of light in RGB.

– lc – light direction vector

• More common used variants of punctual lights are: point, directional, and spot lights.

• Unbound range

58

Page 60: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Ambient light

• Low-frequency lighting.

• Can be represented by a constant or more

complex structures such as lower order

spherical harmonics.

• Mostly used by games

• Often breaks materials

60

Page 62: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Extra 1: Disney BRDF explorer.

• http://www.disneyanimation.com/technolog

y/brdf.html

• Can load GLSL code as an arbitrary

BRDF.

• Can load reference data to compare your

model to real world measurements.

62

Page 64: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Thank you!

64

Page 65: Physically based shadingtume-maailm.pri.ee/ylikool/ComputerGraphicsSeminar/... · 2014-03-18 · Physically based shading Ats Kurvet MTAT.03.296 Computer Graphics Seminar Tartu 2014

Reference

• http://blog.selfshadow.com/publications/s2013-shading-

course/hoffman/s2013_pbs_physics_math_notes.pdf

• http://www.makinggames.de/index.php/magazin/2391_ryse__the_transition_to_physically_based_

shading

• https://www.fxguide.com/featured/game-environments-parta-remember-me-rendering/

• http://interplayoflight.wordpress.com/2013/12/30/readings-on-physically-based-rendering/

• http://www.disneyanimation.com/technology/brdf.html

• http://wiki.nuaj.net/index.php?title=BRDF

• http://www.cs.princeton.edu/~smr/papers/brdf_change_of_variables/brdf_change_of_variables.pdf

• http://renderwonk.com/publications/s2010-shading-

course/snow/sigg2010_physhadcourse_ILM.pdf

• http://www.guerrilla-games.com/presentations/Drobot_Lighting_of_Killzone_Shadow_Fall.pdf

65