Real Shading in Unreal Engine 4 Brian Karis - - PowerPoint PPT Presentation

real shading in unreal engine 4
SMART_READER_LITE
LIVE PREVIEW

Real Shading in Unreal Engine 4 Brian Karis - - PowerPoint PPT Presentation

Real Shading in Unreal Engine 4 Brian Karis (brian.karis@epicgames.com) Goals More realistic image Material layering Better workflow Blended in shader Timely inspiration from Disney Presented in this course last year


slide-1
SLIDE 1

Real Shading in Unreal Engine 4

Brian Karis (brian.karis@epicgames.com)

slide-2
SLIDE 2

Goals

  • More realistic image
  • Material layering

– Better workflow – Blended in shader

  • Timely inspiration from Disney

– Presented in this course last year

slide-3
SLIDE 3

Overview

  • Shading model
  • Material model
  • Lighting model
slide-4
SLIDE 4

Shading Model

slide-5
SLIDE 5
  • Lambert

– Saw little effect of more sophisticated models

Diffuse BRDF

Lambert Burley

slide-6
SLIDE 6

Specular BRDF

  • Generalized microfacet model

– Compared many options for each term – Use same input parameters 𝑔 l, v = 𝐸 h 𝐺(l, h)𝐻 l, v, h 4(n ⋅ l)(n ⋅ v)

slide-7
SLIDE 7

Specular distribution

  • Trowbridge-Reitz (GGX)

– Fairly cheap – Longer tail looks much more natural

GGX Blinn-Phong 𝑔 l, v = 𝐸 h 𝐺(l, h)𝐻 l, v, h 4(n ⋅ l)(n ⋅ v)

slide-8
SLIDE 8

Geometric shadowing

  • Schlick

– Matched to Smith – Cheaper, difference is minor – Uses Disney’s roughness remapping*

n ⋅ v 𝐻𝑇𝑑ℎ𝑚𝑗𝑑𝑙(v) 𝛽 = 0.1 𝛽 = 0.5 𝛽 = 0.9

𝑔 l, v = 𝐸 h 𝐺(l, h)𝐻 l, v, h 4(n ⋅ l)(n ⋅ v)

n ⋅ v 𝐻𝑇𝑛𝑗𝑢ℎ(v)

slide-9
SLIDE 9

Fresnel

  • Schlick

– Approximate the power

Identical for all practical purposes 𝑔 l, v = 𝐸 h 𝐺(l, h)𝐻 l, v, h 4(n ⋅ l)(n ⋅ v)

slide-10
SLIDE 10

Image-based lighting : Problem

  • Only use single sample per environment map
  • Match importance-sampled reference

𝑀𝑗 l 𝑔 l, v 𝑑𝑝𝑡 𝜄l 𝑒l

𝐼

≈ 1 𝑂 𝑀𝑗 l𝑙 𝑔 l𝑙, v 𝑑𝑝𝑡 𝜄l𝑙 𝑞 l𝑙, v

𝑂 𝑙=1

slide-11
SLIDE 11

Image-based lighting : Solution

  • Same as Dimitar’s: split the sum
  • Pre-calculate both parts

1 𝑂 𝑀𝑗 l𝑙 𝑔 l𝑙, v cos 𝜄l𝑙 𝑞 l𝑙, 𝑤

𝑂 𝑙=1

≈ 1 𝑂 𝑀𝑗 l𝑙

𝑂 𝑙=1

1 𝑂 𝑔(l𝑙, v) cos 𝜄l𝑙 𝑞(l𝑙, v)

𝑂 𝑙=1

slide-12
SLIDE 12

Pre-filtered environment map

  • 1st sum stored in cubemap mips

– Pre-filter for specific roughness’s – Fixed distribution, assume n = v – Loses stretched highlights

1 𝑂 𝑀𝑗 l𝑙

𝑂 𝑙=1

≈ Cubemap. Sample(r, mip)

slide-13
SLIDE 13

Environment BRDF

  • 2nd sum stored in 2D lookup texture (LUT)

1 𝑂 𝑔(l𝑙, v) cos 𝜄l𝑙 𝑞(l𝑙, v)

𝑂 𝑙=1

= LUT. r ∗ 𝐺0 + LUT. g

cos 𝜄v

Roughness

slide-14
SLIDE 14

Importance-sampled reference

slide-15
SLIDE 15

Split sum approximation

slide-16
SLIDE 16

Complete approximation (n=v)

slide-17
SLIDE 17

Complete approximation (n=v) Importance-sampled reference Split sum approximation

slide-18
SLIDE 18

Material Model

slide-19
SLIDE 19

Material model

  • BaseColor

– Single color

  • Metallic

– Less chance of error

  • Roughness

– Very clear in its meaning

  • Cavity

– Used for small scale shadowing

Metallic 0 to 1 Non-metal with roughness 0 to 1 Metal with roughness 0 to 1

slide-20
SLIDE 20

Material model lessons

  • Specular parameter is confusing

– Not really needed – Replaced with Cavity

DiffuseColor SpecularColor SpecularPower BaseColor Metallic Specular Roughness BaseColor Metallic Roughness Cavity

Samaritan Infiltrator Now

slide-21
SLIDE 21

Material layering

  • TODO:anotherimage
slide-22
SLIDE 22

Material layering tools

  • Added layers to our node graph based material editor

– Layers use existing material function feature – Added material attributes struct

  • Layer workflow similar to previous texture workflow
slide-23
SLIDE 23

Material layering

slide-24
SLIDE 24

Material layering

slide-25
SLIDE 25

Lighting Model

slide-26
SLIDE 26

Inverse square falloff

Old falloff Inverse square

slide-27
SLIDE 27

Area Lights

slide-28
SLIDE 28

Area light requirements

  • Consistent material appearance

– Energy evaluated with diffuse BRDF and specular BRDF should match

  • Approaches point light model as solid angle approaches zero

– Don’t want to lose any aspect of our shading model

  • Fast enough to use everywhere

– Otherwise artists will bias roughness

slide-29
SLIDE 29

Specular D modification

  • Widen specular distribution by light’s solid angle

– We presented this last year

  • Problems

– Glossy surfaces don’t look glossy anymore

slide-30
SLIDE 30

Reference Specular D modification

slide-31
SLIDE 31

Representative point

  • Pick one representative point on light source shape
  • Shading model can be used directly
  • Point with largest contribution is a good choice
  • Approximate using smallest angle to reflection ray
slide-32
SLIDE 32

Sphere lights

  • Irradiance identical to point light

– If sphere above horizon

  • Closest point between ray and sphere

– Approximates smallest angle

slide-33
SLIDE 33

Sphere light energy conservation

  • Specular distribution has been widened by light’s solid angle

– We already have an approximation for this using “Specular D modification” – Only use normalization term – Divide out original normalization, multiply in new

slide-34
SLIDE 34

Reference Representative point

slide-35
SLIDE 35

Representative point applied to Tube Lights

slide-36
SLIDE 36

In the course notes

  • Tons of extra stuff

– Importance sampling code – Area light formulas – Lots of math 

slide-37
SLIDE 37

Thanks

  • Epic

– Rendering team – All the artists making me look good

  • Special thanks to Sébastien Lagarde
  • Stephen Hill and Stephen McAuley for valuable input
slide-38
SLIDE 38