physically based rendering

59
Physically-Based Rendering Theory and Practice Koray Hagen

Upload: koray-hagen

Post on 26-Jul-2015

326 views

Category:

Software


0 download

TRANSCRIPT

Physically-Based RenderingTheory and Practice

Koray Hagen

The agenda

• Lighting and shading models with live demonstration

• Theoretical basis for PBR with live demonstration

• Q & A

Reality and simulationThree thousand years of research

A brief history

• 4th century B.C.

– Ancient Greeks incorrectly believe vision involves emanations from the eye to the object perceived.

A brief history

• 4th century B.C.

– Ancient Greeks incorrectly believe vision involves emanations from the eye to the object perceived.

– Euclid successfully describes the law of reflection using geometry.

A brief history

• 17th century A.D.

– Kepler, Snell, Fermat, and Descartes contribute to the law of refraction.

A brief history

• 17th century A.D.

– Kepler, Snell, Fermat, and Descartes contribute to the law of refraction.

– Newton observes dispersion, proving light is composed of component colors.

A brief history

• 19th century A.D.

– Fresnel discovers the laws that enable the intensity and polarization of reflected and refracted light to be calculated.

A brief history

• 19th century A.D.

– Fresnel discovers the laws that enable the intensity and polarization of reflected and refracted light to be calculated.

– Maxwell summarizes and extends all current empirical knowledge of optics and electromagnetism with a single set of equations.

A brief history

• 19th century A.D.

– Fresnel discovers the laws that enable the intensity and polarization of reflected and refracted light to be calculated.

– Maxwell summarizes and extends all current empirical knowledge of optics and electromagnetism with a single set of equations.

– Hertz discovers the photoelectric effect.

A brief history

• 20th century A.D.

– Planck discovers a universal constant explaining the relationship between the energy and frequency of an electromagnetic wave.

A brief history

• 20th century A.D.

– Planck discovers a universal constant explaining the relationship between the energy and frequency of an electromagnetic wave.

– Einstein explains the photoelectric effect based on streams of quantized energy packets.

A brief history

• 20th century A.D.

– Planck discovers a universal constant explaining the relationship between the energy and frequency of an electromagnetic wave.

– Einstein explains the photoelectric effect based on streams of quantized energy packets.

– Feynman makes large contributions to quantum field theory and quantum electrodynamics.

A brief history

• 21st century A.D.

– Jet Propulsion Laboratory hires PhD graduate Jim Blinn to work on computer graphics research and simulations for various space missions.

A brief history

• 21st century A.D.

– Jet Propulsion Laboratory hires PhD graduate Jim Blinn to work on computer graphics research and simulations for various space missions.

– These incredible visualizations were shown all over the world.

Our journey to physically based rendering begins here.

Lighting and shading modelsResearch prior to physically based rendering

What is physically-based rendering?

What is physically-based rendering?

• “Many things” and “it depends”

What is physically-based rendering?

• “Many things” and “it depends”

• Must observe how it differs from other older rendering methods.

What is physically-based rendering?

• “Many things” and “it depends”

• Must observe how it differs from other older rendering methods.

• What makes PBR different is in how we reason about the behavior of light and surfaces in computer graphics.

What is physically-based rendering?

• “Many things” and “it depends”

• Must observe how it differs from other older rendering methods.

• What makes PBR different is in how we reason about the behavior of light and surfaces in computer graphics.

• By modeling physical phenomena rather than approximating observation, we can achieve more mathematically stable and photorealistic visual fidelity.

Some terminology

• Lighting model – the behavior of interactions between materials and light sources. Normally attributed to be a topic in physics.

Some terminology

• Lighting model – the behavior of interactions between materials and light sources. Normally attributed to be a topic in physics.

• Shading model – the process of determining the color of a pixel. Normally attributed to be a topic in computer graphics.

Some terminology

• Diffusion and reflection – also known as diffuse and specular reflection.

Some terminology

• Diffusion and reflection – also known as diffuse and specular reflection.

– Describe the most basic separation of light and surface interactions.

Some terminology

• Diffusion and reflection – also known as diffuse and specular reflection.

– Describe the most basic separation of light and surface interactions.

– Specular reflection is the behavior of light hitting a surface boundary and perfectly reflecting off of it, much like how a mirror would behave.

Some terminology

• Diffusion and reflection – also known as diffuse and specular reflection.

– Describe the most basic separation of light and surface interactions.

– Specular reflection is the behavior of light hitting a surface boundary and perfectly reflecting off of it, much like how a mirror would behave..

– Diffusion occurs when not all light reflects from the surface. Some will penetrate into the interior of the illuminated object. There it will either be absorbed by the material (usually converting to heat) or scattered internally.

Some terminology

• Diffusion and reflection – also known as diffuse and specular reflection.

– Describe the most basic separation of light and surface interactions.

– Specular reflection is the behavior of light hitting a surface boundary and perfectly reflecting off of it, much like how a mirror would behave..

– Diffusion occurs when not all light reflects from the surface. Some will penetrate into the interior of the illuminated object. There it will either be absorbed by the material (usually converting to heat) or scattered internally.

• The absorption and scattering of diffuse light are often quite different for different wavelengths of light, which is what gives objects their color (e.g. if an object absorbs most light but scatters blue, it will appear blue).

How was light modeled in 1977?

Blinn-Phong Shading Model

• Every surface is made of some material and each material reflects light differently.

Blinn-Phong Shading Model

• Every surface is made of some material and each material reflects light differently.

– Think of how metal objects are shiny and wooden objects are matte. We need to have a way to specify material parameters that can control how a surface reflects light.

Blinn-Phong Shading Model

• Every surface is made of some material and each material reflects light differently.

– Think of how metal objects are shiny and wooden objects are matte. We need to have a way to specify material parameters that can control how a surface reflects light.

• Every surface can then be approximated with three reflectivity constants, and they control the intensity of the various reflections.

– 𝐾𝑎 ambient reflectivity

– 𝐾𝑠 specular reflectivity

– 𝐾𝑑 diffuse reflectivity

– 𝑎 specular highlighting

Blinn-Phong Shading Model

• By sampling relevant spatial information from a three dimensional scene, the light intensity at point 𝑃 can be calculated.

Blinn-Phong Shading Model

• By sampling relevant spatial information from a three dimensional scene, the light intensity at point 𝑃 can be calculated.

– The normal vector 𝑁 to the surface

– The light vector 𝐿 from the surface

– The view vector 𝑉

Blinn-Phong Shading Model

• By sampling relevant spatial information from a three dimensional scene, the light intensity at point 𝑃 can be calculated.

– The normal vector 𝑁 to the surface

– The light vector 𝐿 from the surface

– The view vector 𝑉

• Lambert’s Law states that the diffusion at a point is proportional to the cosine of the angle between the incoming light ray 𝐿 and the normal of the surface 𝑉.

Blinn-Phong Shading Model

• Diffusion value Ld derived from Lambert’s Law

– Ld = Kd * dot(N, L) * light source intensity

• Specular reflection value Ls– Phong: Ls = Ks * exp(dot(R, V), a) * light source intensity

– Blinn: Ls = Ks * exp(dot(N,H), a) * light source intensity

• Ambient light value La– La = Ka * ambient light intensity

Blinn-Phong Shading Model

• Diffusion value Ld derived from Lambert’s Law

– Ld = Kd * dot(N, L) * light source intensity

• Specular reflection value Ls– Phong: Ls = Ks * exp(dot(R, V), a) * light source intensity

– Blinn: Ls = Ks * exp(dot(N,H), a) * light source intensity

• Ambient light value 𝐿𝑎

– 𝐿𝑎 = 𝐾𝑎 ∙ 𝑎𝑚𝑏𝑖𝑒𝑛𝑡 𝑙𝑖𝑔ℎ𝑡 𝑖𝑛𝑡𝑒𝑛𝑠𝑖𝑡𝑦

• Light intensity at a pixel equals the sum of 𝐿𝑎 + 𝐿𝑠 + 𝐿𝑑

• shader toy example

Blinn-Phong is far from perfect

• Does not respect conversation of energy. As specular power is increased, more energy is lost from the system.

Blinn-Phong is far from perfect

• Does not respect conversation of energy. As specular power is increased, more energy is lost from the system.

• Isn’t expressive enough to simulate more complex materials due to crude approximations of diffusion and reflective properties.

Blinn-Phong is far from perfect

• Does not respect conversation of energy. As specular power is increased, more energy is lost from the system.

• Isn’t expressive enough to simulate more complex materials due to crude approximations of diffusion and reflective properties.

• Ambient lighting completely ignores diffusion properties of environment.

Blinn-Phong is far from perfect

• Does not respect conversation of energy. As specular power is increased, more energy is lost from the system.

• Isn’t expressive enough to simulate more complex materials due to crude approximations of diffusion and reflective properties.

• Ambient lighting completely ignores diffusion properties of environment.

• Terrible workflow for artists, due to final visuals being dependent on physically incorrect “tweaks” on both lighting and art assets. Errors or discrepancies in lighting can propagate to other assets.

Physically-based renderingA modern response to archaic problems

Bidirectional Reflectance Distribution Function

• A function that describes the reflectance properties of a surface. In computer graphics, there are different BRDF models some of which are not physically plausible.

Bidirectional Reflectance Distribution Function

• A function that describes the reflectance properties of a surface. In computer graphics, there are different BRDF models some of which are not physically plausible.

• For a BRDF to be physically plausible, it must be energy conserving and exhibit reciprocity.

Bidirectional Reflectance Distribution Function

• A function that describes the reflectance properties of a surface. In computer graphics, there are different BRDF models some of which are not physically plausible.

• For a BRDF to be physically plausible, it must be energy conserving and exhibit reciprocity.

• Energy conservation states that the total amount of light re-emitted by a surface (reflected and scattered back) is less than the total amount it received.

Microfacet theory

• Both diffuse and specular reflection are dependent on surface irregularities.

Microfacet theory

• Both diffuse and specular reflection are dependent on surface irregularities.

• In practice, the effect of surface roughness on diffuse reflection is much less prominent because of scattering happening inside the material.

Microfacet theory

• Both diffuse and specular reflection are dependent on surface irregularities.

• In practice, the effect of surface roughness on diffuse reflection is much less prominent because of scattering happening inside the material.

– As a result, outgoing reflected light rays are fairly independent of surface roughness and incident direction. The previous Lambertian model completely ignores this.

Microfacet theory

• An example microfacet based specular BRDF would be Cook-Torrance:

– 𝑓(𝑙, 𝑣)𝑚𝑖𝑐𝑟𝑜𝑓𝑎𝑐𝑒𝑡 =𝐷 ℎ 𝐹 𝑣,ℎ 𝐺 𝑙,𝑣,ℎ

4 𝑛∙𝑙 (𝑛∙𝑣)

Microfacet theory

• An example microfacet based specular BRDF would be Cook-Torrance:

– 𝑓(𝑙, 𝑣)𝑚𝑖𝑐𝑟𝑜𝑓𝑎𝑐𝑒𝑡 =𝐷 ℎ 𝐹 𝑣,ℎ 𝐺 𝑙,𝑣,ℎ

4 𝑛∙𝑙 (𝑛∙𝑣)

• Where:– 𝑓𝑚𝑖𝑐𝑟𝑜𝑓𝑎𝑐𝑒𝑡 is the reflectance at normal incident

– 𝐹 is the Fresnel reflectance term

– 𝐺 is the geometry term

– 𝐷 ℎ is the normal distribution term describing how the microfacet normal are distributed

– 𝑙 is the light direction

– 𝑣 is the view direction

– 𝑛 is the surface normal

– ℎ is the half vector between l and v

Microfacet theory

• An example microfacet based specular BRDF would be Cook-Torrance:

– 𝑓(𝑙, 𝑣)𝑚𝑖𝑐𝑟𝑜𝑓𝑎𝑐𝑒𝑡 =𝐷 ℎ 𝐹 𝑣,ℎ 𝐺 𝑙,𝑣,ℎ

4 𝑛∙𝑙 (𝑛∙𝑣)

• Where:– 𝑓𝑚𝑖𝑐𝑟𝑜𝑓𝑎𝑐𝑒𝑡 is the reflectance at normal incident

– 𝐹 is the Fresnel reflectance term

– 𝐺 is the geometry term

– 𝐷 ℎ is the normal distribution term describing how the microfacet normal are distributed

– 𝑙 is the light direction

– 𝑣 is the view direction

– 𝑛 is the surface normal

– ℎ is the half vector between l and v

• The goal is to analytically solve the BRDF.

Microfacet theory

• An example microfacet based specular BRDF would be Cook-Torrance:

– 𝑓(𝑙, 𝑣)𝑚𝑖𝑐𝑟𝑜𝑓𝑎𝑐𝑒𝑡 =𝐷 ℎ 𝐹 𝑣,ℎ 𝐺 𝑙,𝑣,ℎ

4 𝑛∙𝑙 (𝑛∙𝑣)

• Where:– 𝑓𝑚𝑖𝑐𝑟𝑜𝑓𝑎𝑐𝑒𝑡 is the reflectance at normal incident

– 𝐹 is the Fresnel reflectance term

– 𝐺 is the geometry term

– 𝐷 ℎ is the normal distribution term describing how the microfacet normal are distributed

– 𝑙 is the light direction

– 𝑣 is the view direction

– 𝑛 is the surface normal

– ℎ is the half vector between l and v

• Let’s look at what it would take to solve one of the terms.

Fresnel Effect

• The amount of light you see reflected from a surface depends on the viewing angle at which you perceive it.

Fresnel Effect

• The amount of light you see reflected from a surface depends on the viewing angle at which you perceive it.

• None: 𝐹𝑛𝑜𝑛𝑒 𝑣, ℎ = 𝐹0

• Schlick: 𝐹𝑆𝑐ℎ𝑙𝑖𝑐𝑘 𝑣, ℎ = 𝐹0 + 1 − 𝐹0 (1 − 𝑣 ∙ ℎ )5

• Torrance: 𝐹𝐶𝑜𝑜𝑘−𝑇𝑜𝑟𝑟𝑎𝑛𝑐𝑒 = too long to even write …

Fresnel Effect

• The amount of light you see reflected from a surface depends on the viewing angle at which you perceive it.

• None: 𝐹𝑛𝑜𝑛𝑒 𝑣, ℎ = 𝐹0

• Schlick: 𝐹𝑆𝑐ℎ𝑙𝑖𝑐𝑘 𝑣, ℎ = 𝐹0 + 1 − 𝐹0 (1 − 𝑣 ∙ ℎ )5

• Torrance: 𝐹𝐶𝑜𝑜𝑘−𝑇𝑜𝑟𝑟𝑎𝑛𝑐𝑒 = too long to even write …

• Consequently, Schlick’s Approximation has become quite popular in real time graphics due to it’s low computational cost.

Conclusion

• Energy conservation is handled by the shader. A reflected ray is never brighter than the value it had when it first hit the surface.

• The BRDF is handled by the shader. No more magic lighting values, and properties exposed to artists are based in physical reality.

• Naturally will trend to better visual fidelity and photorealism do due basis is physical phenomena.

• Large opportunities in numerical analysis to create performant solutions for solving the needed terms in the BRDF. Fresnel is just one example.

Questions?