Physically Based Shading in Real Time Rendering

92
Physically Based Shading Physically Based Shading in Real Time Rendering in Real Time Rendering Christian Schüler Christian Schüler MBL Development MBL Development

description

Physically Based Shading in Real Time Rendering. Christian Schüler MBL Development. Introduction. Who’s me? Veteran: Engine programming since 15 years Several shipped games Doing “serious” work now but still love games. Introduction. Physically Based Shading Solves some real problems - PowerPoint PPT Presentation

Transcript of Physically Based Shading in Real Time Rendering

Page 1: Physically Based Shading in Real Time Rendering

Physically Based ShadingPhysically Based Shadingin Real Time Renderingin Real Time Rendering

Christian SchülerChristian Schüler

MBL DevelopmentMBL Development

Page 2: Physically Based Shading in Real Time Rendering

Who’s me?Who’s me?

•Veteran: Engine programming since 15 yearsVeteran: Engine programming since 15 years

•Several shipped gamesSeveral shipped games

•Doing “serious” work now but still love gamesDoing “serious” work now but still love games

IntroductionIntroduction

Page 3: Physically Based Shading in Real Time Rendering

Physically Based ShadingPhysically Based Shading

•Solves some real problemsSolves some real problems

•Can make authoring easierCan make authoring easier

•Can improve looksCan improve looks

•Feels as the “right” way to do thingsFeels as the “right” way to do things

•Is going to be implemented in more and more Is going to be implemented in more and more enginesengines

IntroductionIntroduction

Page 4: Physically Based Shading in Real Time Rendering

Ingredients for Physically Based ShadingIngredients for Physically Based Shading

•Linear LightingLinear Lighting

•Energy Preserving SpecularEnergy Preserving Specular

•Metals + DielectricsMetals + Dielectrics

•Fresnel ReflectanceFresnel Reflectance

•Image Based ReflectionsImage Based Reflections

•Microfacet ModelsMicrofacet Models

IntroductionIntroduction

Page 5: Physically Based Shading in Real Time Rendering

Ingredients for Physically Based ShadingIngredients for Physically Based Shading

•Linear LightingLinear Lighting

•Energy Preserving SpecularEnergy Preserving Specular

•Metals + DielectricsMetals + Dielectrics

•Fresnel ReflectanceFresnel Reflectance

•Image Based ReflectionsImage Based Reflections

•Microfacet ModelsMicrofacet Models

IntroductionIntroduction

will talk about these todaywill talk about these todayimportant for content creationimportant for content creation

Page 6: Physically Based Shading in Real Time Rendering

Ingredients for Physically Based ShadingIngredients for Physically Based Shading

•Linear LightingLinear Lighting

•Energy Preserving SpecularEnergy Preserving Specular

•Metals + DielectricsMetals + Dielectrics

•Fresnel ReflectanceFresnel Reflectance

•Image Based ReflectionsImage Based Reflections

•Microfacet ModelsMicrofacet Models

IntroductionIntroduction

programmers and shader programmers and shader authors worry about theseauthors worry about these

Page 7: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #1PBS Ingredient #1

Linear LightingLinear Lighting

Page 8: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

19891989The age of “Pixel Art” and a life-changing The age of “Pixel Art” and a life-changing revelation:revelation:RGB values are not linear!RGB values are not linear!

Page 9: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

too too darkdark

naïvenaïve0—25—50—75—1000—25—50—75—100

correctedcorrected0—50—71—87—1000—50—71—87—100

Page 10: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

RGB values are not linear. RGB values are not linear. This is important for—This is important for—

•Distance and falloff Distance and falloff curvescurves

sharp bordersharp border

Page 11: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

RGB values are not linear. RGB values are not linear. This is important for—This is important for—

•Distance and falloff Distance and falloff curvescurves

•Addition of LightsAddition of Lights

not washed outnot washed out

Page 12: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

RGB values are not linear. RGB values are not linear. This is important for—This is important for—

•Distance and falloff Distance and falloff curvescurves

•Addition of LightsAddition of Lights

•Addition of ColorsAddition of Colors(diffuse + specular)(diffuse + specular)

no color shiftno color shift

Page 13: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

RGB values are not linear. RGB values are not linear. This is important for—This is important for—

•Distance and falloff Distance and falloff curvescurves

•Addition of LightsAddition of Lights

•Addition of ColorsAddition of Colors(diffuse + specular)(diffuse + specular)

•Addition of ColorsAddition of Colors(atmospheric effects)(atmospheric effects)

effect begins earlyeffect begins early

bright bright details still details still

visiblevisible

Page 14: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

Counter-Example:Counter-Example:Not done with linear lightingNot done with linear lightingClassic “computer” lookClassic “computer” look

color shiftcolor shift

falloff, gradient too softfalloff, gradient too soft

color shift and clippingcolor shift and clipping

Page 15: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

Further reading Further reading

•BlogsBlogshttp://filmicgames.com/archives/category/gammhttp://filmicgames.com/archives/category/gammaa

•UnrealUnrealhttp://udn.epicgames.com/Three/TexturingGuidelines.htmlhttp://udn.epicgames.com/Three/TexturingGuidelines.html

•CryEngineCryEnginehttp://freesdk.crydev.net/display/SDKDOC4/Gamma-Correct+Rendering+(sRGhttp://freesdk.crydev.net/display/SDKDOC4/Gamma-Correct+Rendering+(sRGBB))

•UnityUnityhttp://docs.unity3d.com/Documentation/Manual/LinearLighting.htmlhttp://docs.unity3d.com/Documentation/Manual/LinearLighting.html

Page 16: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #2PBS Ingredient #2

Energy Preserving Energy Preserving SpecularSpecular

Page 17: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Assignment:Assignment:Make a Blinn/Phong material with textured Make a Blinn/Phong material with textured glossiness.glossiness.

Page 18: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Assignment:Assignment:Make a Blinn/Phong material with textured glossiness.Make a Blinn/Phong material with textured glossiness.

Why?Why?

Page 19: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

20062006Per pixel varying glossiness for ice materialPer pixel varying glossiness for ice materialSpellforce 2Spellforce 2

smoothsmooth

roughrough

Page 20: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

smoothsmoothhigh glossinesshigh glossiness

roughroughlow glossinesslow glossiness

http://en.wikipedia.org/wiki/File:Frost_patterns_4.jpg

Page 21: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

20092009Per pixel varying glossiness for wet vs dry effectPer pixel varying glossiness for wet vs dry effectVelvet AssassinVelvet Assassin

Page 22: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

20092009Per pixel varying glossiness for wet vs dry effectPer pixel varying glossiness for wet vs dry effectVelvet AssassinVelvet Assassin

glossiness textureglossiness texturealpha channel of specular mapalpha channel of specular map

Page 23: Physically Based Shading in Real Time Rendering

First try:First try:

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Page 24: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

What about the parameterization?What about the parameterization?What are meaningful values to put into a texture?What are meaningful values to put into a texture?

0 ... 10 ... 1 0 ... infinity ?0 ... infinity ?

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

Page 25: Physically Based Shading in Real Time Rendering

What about the parameterization?What about the parameterization?What are meaningful values to put into a texture?What are meaningful values to put into a texture?

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

exponenexponentialtialfunctionfunction

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

0 ... 10 ... 1 1 ... 40961 ... 4096

Page 26: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

In reality, the size of a highlight is linked with its peak brightness.In reality, the size of a highlight is linked with its peak brightness.This is the This is the Energy PreservationEnergy Preservation bit. bit.

high glosshigh gloss

low glosslow gloss

Page 27: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Workflow hazard: Glossiness channel and specular color Workflow hazard: Glossiness channel and specular color channel become dependent on one another!channel become dependent on one another!

glossinessglossinessspecular colorspecular color

dependencydependency

Page 28: Physically Based Shading in Real Time Rendering

Solution: Break the dependency!Solution: Break the dependency!Shader must scale specular color automatically.Shader must scale specular color automatically.

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

exponenexponentialtialfunctionfunction

????

multipliermultiplier

Page 29: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

This multiplier is called the This multiplier is called the normalization factornormalization factor. . Can be computed from a hemispherical integral.Can be computed from a hemispherical integral.Several possibilities, see references.Several possibilities, see references.

normalization normalization factorfactor

integralintegral

Page 30: Physically Based Shading in Real Time Rendering

It starts to get somewhat messy.It starts to get somewhat messy.

PBS Ingredients → Energeticgy Conserving SpecularPBS Ingredients → Energeticgy Conserving Specular

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

exponenexponentialtialfunctionfunction

n+1n+122

n+1n+122

normalizatnormalizationion

factorfactor

Page 31: Physically Based Shading in Real Time Rendering

Why not call that a new kind of material?Why not call that a new kind of material?

PBS Ingredients → Energeticgy Conserving SpecularPBS Ingredients → Energeticgy Conserving Specular

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

Blinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorspecular powerspecular power

exponenexponentialtialfunctionfunction

n+1n+122

n+1n+122

normalizatnormalizationion

factorfactor

Page 32: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Enter the Enter the normalized Blinn/Phong normalized Blinn/Phong material.material.•Accepts a glossiness parameter in the range 0 to Accepts a glossiness parameter in the range 0 to 1.1.•Automatic scale of specular color.Automatic scale of specular color.

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

normalizednormalizedBlinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorglossinessglossiness

normalizednormalizedBlinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorglossinessglossiness

Page 33: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Neat side effect: Neat side effect: Completely parameterized by two RGBA textures.Completely parameterized by two RGBA textures.

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

normalizednormalizedBlinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorglossinessglossiness

normalizednormalizedBlinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorglossinessglossiness

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Page 34: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Further reading Further reading

•BlogsBlogshttp://www.rorydriscoll.com/2009/01/25/energy-conservation-in-games/http://www.rorydriscoll.com/2009/01/25/energy-conservation-in-games/http://seblagarde.wordpress.com/2011/08/17/hello-world/http://seblagarde.wordpress.com/2011/08/17/hello-world/http://www.thetenthplanet.de/archives/http://www.thetenthplanet.de/archives/255255

•UnrealUnrealhttp://udn.epicgames.com/Three/ImageBasedReflections.htmlhttp://udn.epicgames.com/Three/ImageBasedReflections.html

•CryEngineCryEnginehttp://freesdk.crydev.net/display/SDKDOC4/Shadinhttp://freesdk.crydev.net/display/SDKDOC4/Shadingg

Page 35: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #3PBS Ingredient #3

Metals and Metals and DielectricsDielectrics

Page 36: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #3PBS Ingredient #3

Metals and Metals and ......

Page 37: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #3PBS Ingredient #3

Metals and Non-Metals and Non-MetalsMetals

Page 38: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #3PBS Ingredient #3

Metals and Non-Metals and Non-MetalsMetals

aka: “can set diffuse color to zero without everything else aka: “can set diffuse color to zero without everything else messed up”messed up”

Page 39: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #3PBS Ingredient #3

Metals and Non-MetalsMetals and Non-Metalsaka: “can set diffuse color to zero without everything else messed aka: “can set diffuse color to zero without everything else messed

up”up”= no need for an extra “metal shader” (helps batching)= no need for an extra “metal shader” (helps batching)

Page 40: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Assignment:Assignment:What is the difference between metals and non-What is the difference between metals and non-metals?metals?

Page 41: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Assignment:Assignment:What is the difference between metals and non-What is the difference between metals and non-metals?metals?

Are metals “somehow grey”?Are metals “somehow grey”?

Page 42: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Assignment:Assignment:What is the difference between metals and non-What is the difference between metals and non-metals?metals?

Are metals “especially shiny”?Are metals “especially shiny”?

Page 43: Physically Based Shading in Real Time Rendering

Assignment:Assignment:What is the difference between metals and non-What is the difference between metals and non-metals?metals?

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

But surely they But surely they have have

““lots of specular”?lots of specular”?

Page 44: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

metalmetalnon-greynon-grey

non-metalnon-metalhigh glossinesshigh glossiness

non-metalnon-metallow glossinesslow glossiness

metalmetallow glossinesslow glossiness

metalmetalhigh glossinesshigh glossiness

Page 45: Physically Based Shading in Real Time Rendering

Metals are pure reflection,Metals are pure reflection,characterized by the characterized by the absenceabsence of a diffuse component. of a diffuse component.

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

non-metalnon-metaldiffusediffuse + + specularspecular

metal metal specularspecular only only

Page 46: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

specular specular reflectionreflectionmore or less glossymore or less glossy

incoming lightincoming light

surfacesurfacemore or less smoothmore or less smooth

Specular reflection happens on the surfaceSpecular reflection happens on the surface

Page 47: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

This is still specular reflectionThis is still specular reflection

specular specular reflectionreflectionall over the placeall over the place

incoming lightincoming light

surfacesurfaceextremely roughextremely rough

Page 48: Physically Based Shading in Real Time Rendering

specular specular reflectionreflectionall over the placeall over the place

incoming lightincoming light

surfacesurfaceextremely roughextremely rough

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

This is still specular reflectionThis is still specular reflection

100% specular100% specular

Page 49: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

incoming lightincoming light

moleculesmolecules

Diffuse reflection happens Diffuse reflection happens belowbelow the surface the surfaceCompletely different physical processCompletely different physical process

diffuse reflectiondiffuse reflectionabsorption and re-absorption and re-emissionemission

Page 50: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Diffuse reflection happens Diffuse reflection happens belowbelow the surface the surfaceCompletely different physical processCompletely different physical process

incoming lightincoming light

moleculesmolecules

diffuse reflectiondiffuse reflectionabsorption and re-absorption and re-emissionemission

100% diffuse100% diffuse(no solid surface (no solid surface

at all)at all)

Page 51: Physically Based Shading in Real Time Rendering

incoming lightincoming light

moleculesmolecules

diffuse reflectiondiffuse reflectionabsorption and re-absorption and re-emissionemission

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

100% diffuse100% diffuse(no solid surface (no solid surface

at all)at all)

Metals (electrical conductors) cannot have thisMetals (electrical conductors) cannot have this

Page 52: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Ok, so lets give this a tryOk, so lets give this a tryForce the diffuse color to zero—does this look like Force the diffuse color to zero—does this look like a metal?a metal?

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

normalizednormalizedBlinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorglossinessglossiness

normalizednormalizedBlinn/Blinn/PhongPhong

diffuse colordiffuse coloropacityopacityspecular colorspecular colorglossinessglossiness

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

ConstantConstant

colorcolor

ConstantConstant

colorcolor

Page 53: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Software: GLC Player 2.3Software: GLC Player 2.3Model: Model: http://www.3dm3.com/modelsbank/model76.htm

Oh no!Oh no!Ambient is Ambient is gone!gone!

Looks like black plasticLooks like black plastic

Page 54: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Must have “ambient” Must have “ambient” models for both diffuse models for both diffuse and specular.and specular.

Here: Hemisphere lightHere: Hemisphere light(sky+ground color)(sky+ground color)

So much So much nicernicer

Page 55: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

diffusediffuse specularspecularlow glossinesslow glossiness

specularspecularhigh glossinesshigh glossiness

direct lightdirect light

hemisphere lighthemisphere light

Page 56: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

diffusediffuse specularspecularlow glossinesslow glossiness

specularspecularhigh glossinesshigh glossiness

direct light + hemisphere light direct light + hemisphere light

Page 57: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

diffuse+speculadiffuse+specularr

low glossinesslow glossiness

diffuse+speculadiffuse+specularr

high glossinesshigh glossiness

direct light + hemisphere light direct light + hemisphere light

Page 58: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

20062006World globe with purely specular surfaceWorld globe with purely specular surfaceSpellforce 2: Dragon StormSpellforce 2: Dragon Storm

directdirect

groundground

^̂̂̂ skysky

Page 59: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

20092009Wodden collectible box with metal ornamentWodden collectible box with metal ornament Velvet AssassinVelvet Assassin

diffusediffuse specularspecular glossinesglossinesss

Page 60: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

20092009Wodden collectible box with metal ornamentWodden collectible box with metal ornament Velvet AssassinVelvet Assassin

Velvet AssassinVelvet Assassindiffusediffuse specularspecular glossinesglossines

ss

Page 61: Physically Based Shading in Real Time Rendering

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

20092009Wodden collectible box with metal ornamentWodden collectible box with metal ornament Velvet AssassinVelvet Assassin

Velvet AssassinVelvet Assassindiffusediffuse specularspecular glossinesglossines

ss

Page 62: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

PBS Ingredient #4PBS Ingredient #4

Fresnel ReflectanceFresnel Reflectance

Page 63: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Fresnel effect (no news Fresnel effect (no news here)—here)—

•Increasing reflectivity Increasing reflectivity towards grazing angletowards grazing angle

Page 64: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Fresnel effect (no news Fresnel effect (no news here)—here)—

•Increasing reflectivity Increasing reflectivity towards grazing angletowards grazing angle

•Very prominent on waterVery prominent on water

Page 65: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Fresnel effect (no news Fresnel effect (no news here)—here)—

•Increasing reflectivity Increasing reflectivity towards grazing angletowards grazing angle

•Very prominent on waterVery prominent on water

•In theory, everything In theory, everything becomes a perfect mirror becomes a perfect mirror at the grazing limitat the grazing limit

http://de.wikipedia.org/wiki/Fresnelsche_Formeln

Page 66: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Fresnel effect (no news here)—Fresnel effect (no news here)—

•Increasing reflectivity towards Increasing reflectivity towards grazing anglegrazing angle

•Very prominent on waterVery prominent on water

•In theory, everything In theory, everything becomes a perfect mirror at becomes a perfect mirror at the grazing limitthe grazing limit

•Corollary: Everything Is Shiny!Corollary: Everything Is Shiny!http://filmicgames.com/archives/547http://filmicgames.com/archives/547

Page 67: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Fresnel reflectance can be used to classify materialsFresnel reflectance can be used to classify materials

R(90°) is the R(90°) is the samesame

for all ...for all ...

... but R(0°) is different for ... but R(0°) is different for each.each.

Page 68: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Non-metals are Non-metals are here (2% to 8%)here (2% to 8%)

Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

Page 69: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Metals are here Metals are here (60% to 90%)(60% to 90%)

most are colored most are colored to some degreeto some degree

Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

Page 70: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Semiconductors Semiconductors and crystals are and crystals are here here (15% to 50%)(15% to 50%) http://en.wikipedia.org/wiki/

Sapphire

Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

Page 71: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

Non-metals are Non-metals are here (2% to 8%)here (2% to 8%)

Metals are here Metals are here (60% to 90%)(60% to 90%)

Semiconductors Semiconductors and crystals are and crystals are here here (15% to 50%)(15% to 50%)

Page 72: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

An approximation: all curves are fairly well predicted An approximation: all curves are fairly well predicted by R(0°)by R(0°)

Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

Page 73: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Physically Based Shading uses this as “specular color”Physically Based Shading uses this as “specular color”

Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

2%2%

5%5%

10%10%

20%20%

50%50%

80%80%

Page 74: Physically Based Shading in Real Time Rendering

Physically Based Shading uses this as “specular color”Physically Based Shading uses this as “specular color”

rememberremember

Linear Linear

Lighting?Lighting?

2%2%

5%5%

10%10%

20%20%

50%50%

80%80%Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Page 75: Physically Based Shading in Real Time Rendering

Physically Based Shading uses this as “specular color”Physically Based Shading uses this as “specular color”

rememberremember

Linear Linear

Lighting?Lighting?

2%2%

5%5%

10%10%

20%20%

50%50%

80%80%Fresnel reflectance can be used to Fresnel reflectance can be used to classify materialsclassify materials

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Page 76: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Non-metals (2% to Non-metals (2% to 8%)8%)

Metals (60% to Metals (60% to 90%)90%)

Semiconductors Semiconductors and crystals (15% and crystals (15%

to 50%)to 50%)

2%2%

5%5%

10%10%

20%20%

50%50%

80%80%

??

??

??

??

??

??

RealityReality RGB (gamma RGB (gamma 2.2)2.2)

Specular Color ChartSpecular Color Chart

Page 77: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Non-metals (2% to Non-metals (2% to 8%)8%)

Metals (60% to Metals (60% to 90%)90%)

Semiconductors Semiconductors and crystals (15% and crystals (15%

to 50%)to 50%)

2%2%

5%5%

10%10%

20%20%

50%50%

80%80%

16%16%

25%25%

35%35%

48%48%

76%76%

90%90%

RealityReality RGB (gamma RGB (gamma 2.2)2.2)

Specular Color ChartSpecular Color Chart

Page 78: Physically Based Shading in Real Time Rendering

PBS Ingredients → Fresnel ReflectancePBS Ingredients → Fresnel Reflectance

Further reading Further reading

•BlogsBlogshttp://seblagarde.wordpress.com/2012/04/30/dontnod-specular-and-glossinesshttp://seblagarde.wordpress.com/2012/04/30/dontnod-specular-and-glossiness-chart-chart//

•Real Time Rendering, 3rd EditionReal Time Rendering, 3rd Editionhttp://www.realtimerendering.comhttp://www.realtimerendering.com

•ShaderX 7ShaderX 7http://www.shaderx7.comhttp://www.shaderx7.com

•SIGGRAPH Course on PBS SIGGRAPH Course on PBS (2010)(2010) http://bit.ly/s10shadershttp://bit.ly/s10shaders(2012) (2012) http://bit.ly/s12shadershttp://bit.ly/s12shaders

Page 79: Physically Based Shading in Real Time Rendering

ConclusionConclusion

Page 80: Physically Based Shading in Real Time Rendering

ConclusionConclusion

Page 81: Physically Based Shading in Real Time Rendering

ConclusionConclusion

normalizednormalizedBlinn/PhongBlinn/Phong

diffuse colordiffuse coloropacityopacityspecular specular colorcolorglossinessglossiness

normalizednormalizedBlinn/PhongBlinn/Phong

diffuse colordiffuse coloropacityopacityspecular specular colorcolorglossinessglossiness

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

Page 82: Physically Based Shading in Real Time Rendering

normalizednormalizedBlinn/PhongBlinn/Phong

diffuse colordiffuse coloropacityopacityspecular specular colorcolorglossinessglossiness

normalizednormalizedBlinn/PhongBlinn/Phong

diffuse colordiffuse coloropacityopacityspecular specular colorcolorglossinessglossiness

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

TextureTexture

colorcoloralphaalpha

ConclusionConclusion

diffusediffuse speculspecularar

glossinglossinessess

Page 83: Physically Based Shading in Real Time Rendering

Physically Based Shading Physically Based Shading

•Is going to be implemented in more and more Is going to be implemented in more and more enginesengines

•Affects content creation, mostly texturingAffects content creation, mostly texturing

•Affects how you think about colors and numbersAffects how you think about colors and numbers

ConclusionConclusion

Page 84: Physically Based Shading in Real Time Rendering

Thank YouThank You

Page 85: Physically Based Shading in Real Time Rendering

Contact InformationContact Information

[email protected]@mbldev.com

More information and links to related material on More information and links to related material on my blogmy blog

http://http://www.thetenthplanet.dewww.thetenthplanet.de

Page 86: Physically Based Shading in Real Time Rendering

Bonus SlidesBonus Slides

Page 87: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

Other ingredients of Physically based lightingOther ingredients of Physically based lighting

•Image based reflectionsImage based reflectionsUse an environment map instead of a simple Use an environment map instead of a simple hemispherehemisphereAutomatic mipmap selection based on glossinessAutomatic mipmap selection based on glossiness

Page 88: Physically Based Shading in Real Time Rendering

PBS IngredientsPBS Ingredients

Other ingredients of Physically based lightingOther ingredients of Physically based lighting

•Real-Time Microfacet ModelReal-Time Microfacet ModelUsually based on a Cook-Torrance approximationUsually based on a Cook-Torrance approximationGives more “oomph” in backlight scenarios than Gives more “oomph” in backlight scenarios than Fresnel onlyFresnel only

•(insert Velvet Assassin screenshot)(insert Velvet Assassin screenshot)

Page 89: Physically Based Shading in Real Time Rendering

PBS Ingredients → Display Gamma and Linear LightingPBS Ingredients → Display Gamma and Linear Lighting

Linear Lighting TimelineLinear Lighting Timeline

Silicon Graphics, 3dfx Voodoo, etcSilicon Graphics, 3dfx Voodoo, etcfixed 1.8 gamma rampfixed 1.8 gamma ramppre 1996pre 1996

19961996 QuakeQuakeMicrosoft + HP define sRGB (gamma 2.2)Microsoft + HP define sRGB (gamma 2.2)

20022002Linear lighting becomes feasible with Linear lighting becomes feasible with DirectX 9DirectX 9

20082008 OpenGL supports sRGBOpenGL supports sRGB

20062006 Spellforce 2: Shadow WarsSpellforce 2: Shadow Wars

20072007 Crysis + CryEngineCrysis + CryEngine

20052005 Unreal Engine 3 announcedUnreal Engine 3 announced

20112011 Unity Engine 3.5Unity Engine 3.5

{{

Dark

D

ark

A

ges

Ag

es

Page 90: Physically Based Shading in Real Time Rendering

PBS Ingredients → Energy Preserving SpecularPBS Ingredients → Energy Preserving Specular

Energy Preserving Specular TimelineEnergy Preserving Specular Timeline

19941994 Lafortune & WillemsLafortune & Willems“Modified Phong Reflectance Model”“Modified Phong Reflectance Model”

20062006 Spellforce 2: Shadow WarsSpellforce 2: Shadow Wars

20092009 Velvet AssassinVelvet Assassin

20112011

Unreal Engine 3 Unreal Engine 3 enabled as “Image Reflection Specular”enabled as “Image Reflection Specular”

CryEngine 3CryEngine 3enabled with alpha channel in specular textureenabled with alpha channel in specular texture

20102010 Call of Duty: Black OpsCall of Duty: Black Ops

20132013 Remember MeRemember Me

Page 91: Physically Based Shading in Real Time Rendering

incoming lightincoming light

moleculesmolecules

diffuse reflectiondiffuse reflectionabsorption and re-absorption and re-emissionemission

PBS Ingredients → Metals and DielectricsPBS Ingredients → Metals and Dielectrics

Metals (electrical conductors) cannot have thisMetals (electrical conductors) cannot have this

Plasma is an electrical Plasma is an electrical conductor, too.conductor, too.

The sun: emissive + specularThe sun: emissive + specular

Page 92: Physically Based Shading in Real Time Rendering

Bonus→ Energy Preserving SpecularBonus→ Energy Preserving Specular

20062006Per pixel varying glossinessPer pixel varying glossinessIce material in Spellforce 2Ice material in Spellforce 2