unite2014: mastering physically based shading in unity 5

64
Mastering Physically Based Shading in Unity 5 Renaldas Zioma / Unity @__ReJ__ Erland Körner / Unity Wes McDermott / Allegorithmic

Upload: renaldas-zioma

Post on 12-Nov-2014

8.414 views

Category:

Technology


9 download

DESCRIPTION

Light introduction to Physically Based Shading. Presentation discusses theory behind light interaction with different materials, new Standard shader in Unity5 and how to prepare data for your Physically Based workflow.

TRANSCRIPT

Page 1: Unite2014: Mastering Physically Based Shading in Unity 5

Mastering Physically Based Shading in Unity 5

Renaldas Zioma / Unity @__ReJ__ Erland Körner / Unity Wes McDermott / Allegorithmic

Page 2: Unite2014: Mastering Physically Based Shading in Unity 5

Physically Based Shading in Unity 5

Page 3: Unite2014: Mastering Physically Based Shading in Unity 5

One shader

Page 4: Unite2014: Mastering Physically Based Shading in Unity 5

Our past• Butterfly Effect demo • Inspiration from Mental Images Architectural (MIA) shader • Inspiration from Disney SIGGRAPH’12 talk • Secret Aim: look identical /w Marmoset Toolbag 2

4

Page 5: Unite2014: Mastering Physically Based Shading in Unity 5

Natural Materials• Metals • Non-metals (Dielectrics) • monolithic materials: plastic, rock, water … • cloth • organic

5

vs

Page 6: Unite2014: Mastering Physically Based Shading in Unity 5

Dielectrics• Most objects in natural environments are dielectrics

Page 7: Unite2014: Mastering Physically Based Shading in Unity 5

Dielectrics Distinguishing Traits

7

• Hard to see your own image in the reflection • Much more reflective on the edge • Augustin Fresnel (1788-1827)

Page 8: Unite2014: Mastering Physically Based Shading in Unity 5

• Surface reflects almost* the same fraction of light for any dielectric • Light penetrates the surface

• on atomic level a lot of space for light photons to pass through

• Light is scattered under the surface

Dielectrics All are almost the same

* though gems can be 2-3 times more reflective than glass

Page 9: Unite2014: Mastering Physically Based Shading in Unity 5

Dielectrics Specular Reflection• Light bounces of the surface • NO color change!

• Surface irregularities will affect spread of the bounce

Page 10: Unite2014: Mastering Physically Based Shading in Unity 5

• Subsurface scattering • Crystallites, cells, fibers - will absorb and reflect light • different color • random directions

• Otherwise light just passes through • liquids, some plastics, gems

Dielectrics Diffuse Reflection

Scattering

Page 11: Unite2014: Mastering Physically Based Shading in Unity 5

• Surface micro-structure • rough vs smooth

• Diffuse reflection (absorption & scattering) • we perceive it as a color of material

• Slight variation in amount of light bounced in specular reflection • sometimes denoted as F0 • governed by the Index Of Refraction of material • 2-4% (IOR 1.3 .. 1.8) • gems are outliers 7%-13% (IOR 1.2 .. 2.6) 11

Dielectrics Why then they look different?

Page 12: Unite2014: Mastering Physically Based Shading in Unity 5

12

Metals

Page 13: Unite2014: Mastering Physically Based Shading in Unity 5

• Very good mirrors (if smooth) • Colored reflection • Surface is impenetrable to light • can’t be transparent *

Metals Distinguishing Traits

13* well, actually some metals can be made into semi-transparent, if really really thin!

Page 14: Unite2014: Mastering Physically Based Shading in Unity 5

Electromagnetic field

Metals Specular Reflection• Lots of free electrons! • light is bounced back • “prevent” light penetrating the surface

• Fraction of light is absorbed at the surface • color tinted reflection

Page 15: Unite2014: Mastering Physically Based Shading in Unity 5

Metals What makes different looking metals• Color of specular reflection • we perceive it as a color of metal

• Surface micro-structure • rough vs polished

Page 16: Unite2014: Mastering Physically Based Shading in Unity 5

Half-correct summary*

* works only for pure materials

• Metals • No diffuse • Very strong specular • Colored specular (reddish, yellowish)

• Non-metals • Strong Fresnel • Very weak specular at normal incidence • Monochromatic specular • Colored diffuse (any color)

Page 17: Unite2014: Mastering Physically Based Shading in Unity 5

Materials are rarely pure or ideal

Page 18: Unite2014: Mastering Physically Based Shading in Unity 5

Materials are rarely pure or ideal• Metals • No diffuse - rust, oxidization, mix /w other materials …

• Non-metals • Strong Fresnel - not for rough surfaces • Very weak specular at normal incidence • Monochromatic specular • Multilayer materials can have stronger tinted specular • dielectric mirrors, cloths like tarpaulin, vegetation …

Page 19: Unite2014: Mastering Physically Based Shading in Unity 5

Materials are rarely pure or ideal• That is why we pick Diffuse+Specular workflow • but there are definite upsides in the Metallic workflow too! !

• btw, some call this workflow: • Albedo+Reflectivity • Specular+Gloss

Page 20: Unite2014: Mastering Physically Based Shading in Unity 5

So what is this Specular, again?• Controls reflectivity at normal incidence • Plastic (IOR 1.5) • 4%

!• Some Crystal (IOR 2.1) • 13%

!• Aluminium • 95%

20

Page 21: Unite2014: Mastering Physically Based Shading in Unity 5

So what is this Specular, again?• Plastic (IOR 1.5) • 4% in Linear • (59, 59, 59) in sRGB

• Some Crystal (IOR 2.1) • 13% • (100, 100, 100) in sRGB

• Silver • 95% • (249, 249, 249) in sRGB

Page 22: Unite2014: Mastering Physically Based Shading in Unity 5

So what is this Specular, again?• Silver !• Copper !• Gold !• Aluminum !• Iron

22

gold

copper

silver

refle

ctan

ce %

visible spectrum

Page 23: Unite2014: Mastering Physically Based Shading in Unity 5

Smoothness• Controls Fresnel - reflectivity at grazing angle • Controls blurriness of reflection • Very rough surfaces • Disney diffuse • cloth

23

Page 24: Unite2014: Mastering Physically Based Shading in Unity 5

24

Standard shader break down

Page 25: Unite2014: Mastering Physically Based Shading in Unity 5

Direct Light

25

Page 26: Unite2014: Mastering Physically Based Shading in Unity 5

Diffuse reflection

26

Page 27: Unite2014: Mastering Physically Based Shading in Unity 5

Indirect Light

27

Page 28: Unite2014: Mastering Physically Based Shading in Unity 5

+ Indirect Light * AO

28

Page 29: Unite2014: Mastering Physically Based Shading in Unity 5

+ Fresnel

29

Page 30: Unite2014: Mastering Physically Based Shading in Unity 5

Metallic Reflections

30

Page 31: Unite2014: Mastering Physically Based Shading in Unity 5

(or) Dielectric Reflections

31

Page 32: Unite2014: Mastering Physically Based Shading in Unity 5

Reflections /w Smoothness

32

Page 33: Unite2014: Mastering Physically Based Shading in Unity 5

Reflections * Specular

33

Page 34: Unite2014: Mastering Physically Based Shading in Unity 5

+ Reflections * Specular * AO

34

Page 35: Unite2014: Mastering Physically Based Shading in Unity 5

= Final result

35

Page 36: Unite2014: Mastering Physically Based Shading in Unity 5

What are the benefits!?• Accurate, realistic material representation • Consistent and predictable workflow and artwork • For everyday materials • …but also stylised look

36

Page 37: Unite2014: Mastering Physically Based Shading in Unity 5

The Standard shader• Compact • Folds • Thumbnails • Expandable

37

Page 38: Unite2014: Mastering Physically Based Shading in Unity 5

Standard shader - Primary inputs• Diffuse [RGB] • Specular [RGB] • defines material type

• Smoothness [greyscale A] • character of the surface

• Normal Map [Tangent Space]

38

Page 39: Unite2014: Mastering Physically Based Shading in Unity 5

Additionally…• Occlusion [greyscale] • Height map - Parallax [greyscale] • Emission - HDR range [RGB] • UV set selection • Detail maps (overlay) • Diffuse and Normal maps • Blended with Mask texture

• Opaque, Cut-out, Transparent

39

Page 40: Unite2014: Mastering Physically Based Shading in Unity 5

Detail overlay

40

Page 41: Unite2014: Mastering Physically Based Shading in Unity 5

UV set selection and Masking

41

Page 42: Unite2014: Mastering Physically Based Shading in Unity 5

Normalmap overlay

42

Page 43: Unite2014: Mastering Physically Based Shading in Unity 5

Emission

43

Page 44: Unite2014: Mastering Physically Based Shading in Unity 5

Lighting in 5.0• Lights • Environment • ambient probe • light probes • default reflection • reflection probes

• Lightmaps • HDR IBL

44

Global Localized

Diffuse Ambient Probe Light Probes

Specular Default Reflection Reflection Probes

Page 45: Unite2014: Mastering Physically Based Shading in Unity 5

Environment lighting• Ties materials into environment • Lights must match surrounding • Exposure • HDR on Main camera • …in scene view • …tone mapping too

45

Page 46: Unite2014: Mastering Physically Based Shading in Unity 5

• Auto generated from Skybox • Directional light • Specular reflection • Ambient probe

46

Light Setups Default, Simple, Out-of-the-Box

Page 47: Unite2014: Mastering Physically Based Shading in Unity 5

• Specify your own IBL texture • Use “Specular Convolution” in

Texture Import settings • Setup your own ambient probe • Top, Equator, Bottom • Or script code

47

Light Setups Custom Image Based

Page 48: Unite2014: Mastering Physically Based Shading in Unity 5

• Reflection Probes - convolved HDR Specular cubemaps • HDR Texture import • .hdr and .exr formats

• Up to 8K resolution

48

Light Setups Reflection Probes, Light Probes and cubemaps

Page 49: Unite2014: Mastering Physically Based Shading in Unity 5

• Diffuse / Albedo • No lighting information • Metals are typically dark

Painted Texture Example

49

Page 50: Unite2014: Mastering Physically Based Shading in Unity 5

• Specular • Defines material type • Small variation among

dielectrics • Dielectrics are monochrome

greyscale

Painted Texture Example

50

Page 51: Unite2014: Mastering Physically Based Shading in Unity 5

Painted Texture Example• Specular, continued… • Similar hue as Diffuse if metal • Suggested range 40-75 sRGB

for non-metals. • 155-255 sRGB for metals

51

Page 52: Unite2014: Mastering Physically Based Shading in Unity 5

Painted Texture Example• Smoothness • Lots of details! • Range between 0.12-.94

52

Page 53: Unite2014: Mastering Physically Based Shading in Unity 5

Painted Texture Example• Occlusion - Cavities, Creases • Mask reflections • Mask indirect bounce

53

Page 54: Unite2014: Mastering Physically Based Shading in Unity 5

Obtaining texture data• Scanned - “scientific method” • Quixel Megatexture, Substance DB,

Surface mimic, … • Hand painted • Time-consuming to match values • Need to remove lighting information • Reference charts (DontNod, Quixel, …)

• Procedural • Substance, among others…

54

Page 55: Unite2014: Mastering Physically Based Shading in Unity 5

55

Case Study Procedural workflow with Substance

Page 56: Unite2014: Mastering Physically Based Shading in Unity 5

Substance• Specialize in texture creation

tools built around Physically Based Shading • Substance file : streamlined

solution for using PBS in Unity • Input doesn’t matter : content

packaged as Substance • Automatically connect outputs

to shader • Exposed parameters with

runtime support

Page 57: Unite2014: Mastering Physically Based Shading in Unity 5

Physically Based Templates• Supports Metal/Rough, Spec/Gloss and

Custom PBR • Based on Disney Principled GGX BRDF

*cross-checked by AAA game studios

Page 58: Unite2014: Mastering Physically Based Shading in Unity 5

Material Workflow

• Material Blending

Substance Designer

Page 59: Unite2014: Mastering Physically Based Shading in Unity 5

Material Workflow• Weathering Filters : Propagate effect across

multiple channels

Substance Designer and Substance Painter

Page 60: Unite2014: Mastering Physically Based Shading in Unity 5

Material Painting• Paint across multiple channels • 100% Non-Destructive • Export to Unity

60

Substance Painter

Page 61: Unite2014: Mastering Physically Based Shading in Unity 5

Substance Database• Growing library of PBR materials as Substances

• Hand-painted • Procedural • Custom database

Page 62: Unite2014: Mastering Physically Based Shading in Unity 5

Custom Tools• PBS Materials

• Dielectric • Metal • PBS Map Validation

Custom Nodes PBR Validation Node

Page 63: Unite2014: Mastering Physically Based Shading in Unity 5

Native Unity Support• Reduce texture package

size • Change parameters at

runtime • Quick texture iterations

Page 64: Unite2014: Mastering Physically Based Shading in Unity 5

Q&A

64