SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010...

42

Transcript of SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010...

Page 1: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.
Page 2: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

SIGGRAPH 2010

Physically Based Shading Models

in Film and Game Production

- Practical implementation at tri-Ace

Yoshiharu GotandaResearch and Development Department

tri-Ace, Inc.

Page 3: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

History

• Non-physical Blinn-Phong model, as commonly used in games

GHNFFRLNR nsd ))(()( 0

5000 )1)(1()( HEFFFF

n : Shininess (cosine power)

Rd : Diffuse color

Rs : Specular color

F0 : Fresnel coefficient

G : Geometry Attenuation

Page 4: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Difficulty with ad-hoc models

• Artists tend to have difficulty matching physical accurate values– Even if one object has a 1,000x stronger

specular than another, they don’t set those values

• Difficult to see this dynamic difference inLow Dynamic Range (LDR) images

– Problem with Schlick’s approximationin production

Wrong setting

Page 5: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Problem with Schlick’s approximation

• Fresnel term is implemented withSchlick’s approximation– For Blinn model shaders and Fresnel shaders

• Previously, artists directly set f0 parameter in a tool

– e.g. A material has a refractive index of 1.5,setting f0 to 0.04 is correct and means

» Reflection ratio between normal and glancing direction is 25– But…

Page 6: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Problem with Schlick’s approximation

• 25x specular variance is not intuitively acceptable by artists

25x specular variance

f0 = 0.04

f0 = 0.04 with a refractive index of 1.5

Page 7: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Problem with Schlick’s approximation

• Then, an artist incorrectly sets 0.3 or 0.5based on their intuition– Consequently normal reflectance becomes stronger

• Specular looks too strong compared to reality

• The artist reduces specular intensity– Specular looks too weak at glancing angles

• Specular highlight on the edge with back lightingcan’t be represented

Page 8: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

If f0 is too large

Too weak specular on edge

Too strong specular in normal direction

Too small specular value Correct Too high Fresnel value

Page 9: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Our solution

• Parameters for Fresnel are changed to use either• Complex refractive indices OR • Prebuilt material templates

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Page 10: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Why physically based?

• Artists can more easily manipulate the parameters– Fewer parameters and

textures– Shader guarantees physically

correct appearance

Page 11: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Our BRDF model

• Blinn-Phong based BRDF

),max(

))((

)22(4

)2()(1 0

2

0 ENLN

HNFFnFF

Rn

spec

ndiffd

Our customized Blinn-Phong

5000 )1)(1()( LNFFFFdiff

5000 )1)(1()( HEFFFFspec

n : Shininess (cosine power)

Rd : Diffuse albedo

F0 : Normal Specular Reflectance

Details on how we derived this expression are in the course notes

Page 12: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Normalization Factor Approximation

• The result is expensive for real-time– Therefore, we approximate it with a linear function instead

)22(4

2

2

n

n

Normalization Factor

shininess

0 8 5 6 8 3 2.00 3 9 7 4 3 6.0 n

Page 13: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Final Model

• Diffuse term is also approximated for performance

),max(

))(()0856832.00397436.0(1 0

0 ENLN

HNFFnF

Rn

specd

Our customized model

5000 )1)(1()( HEFFFFspec

Page 14: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Comparison

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Ad-hoc

Our spectral model

Page 15: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Comparison - shininess map only

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Ad-hoc

Our model

Page 16: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Comparison - reflectance map only

Ad-hoc with specular color map

Our modelOur spectral model

Page 17: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Comparison

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game ProductionAd-hoc Our model

Ad-hoc Our Spectral model

Page 18: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Comparison - shininess map only

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game ProductionAd-hoc Our model

Ad-hoc Spectral model

Page 19: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Comparison - metal

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Aluminum Copper Titanium

Our spectralmodel

Our metalmodel

Page 20: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Other shader variations

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Marschner Kajiya-Kay

Page 21: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Other shader variations

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Ashikhmin-Shirley Our anisotropic model

Page 22: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Problem with ambient lighting

• Even with physically-based shading models, ambient lighting is still not physically-based– Ambient term is typically computed as a constant

• Based on a diffuse only term• Based on arbitrary value between diffuse and specular terms

• Ideally, ambient lighting should be computed as spherical area lighting with a proper BRDF

Page 23: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Problem with ambient lighting

• Quality degrades in scenes mainly lit by ambient lighting– Shadowed areas– Inside a house lit only by daylight (no artificial lights)– Cloudy outside

Page 24: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Ambient lighting improvements

• Spherical Harmonic lighting– Irradiance or SH

volumes

• Image based lighting (environment mapping)

• Ambient occlusion

Ambient Occlusion OFF Ambient Occlusion ON

Page 25: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Problem with ambient lighting

Page 26: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

Manual solutions

• Artists have fought against the problem by hand– Put secondary lights

• Rim light, fill light

– Build a special shader• Solve the problem using our highly flexible shader system• Non-physical solution

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Page 27: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Manual solutions

No solution Special shader by an artist(No BRDF solution)

Manual lighting

Page 28: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Ambient BRDF

• A new BRDF model for ambient shading– In order to improve quality of ambient shading

• Specular and diffuse components are computed taking into account ambient lighting

• Ambient term is no longer a constant– Ambient lighting is regarded as area lighting

Page 29: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

BRDF integral for ambient shading

• Integrate a BRDF model over hemisphere– The results are stored in a linear (non-swizzled) volume texture

• U – (E ・ N) : dot product of eye and normal vector

• V – shininess

• W – f0

dLNfnfnf ))(,,,(),,( 00

orlight vect :

vectoreye :

ereflectancspecular normal :

shininess :

model BRDF :

0

f

n

Page 30: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Ambient BRDF Shading

• Use the volume texture in pixel shader– Specular term is computed as texture fetch

• The texture directly stores the specular term

– Diffuse term is Rd*(1 – specular)• Ideally diffuse term should be stored in the texture for

accurate result• In our case, diffuse term is approximated for performance

Page 31: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Color terms for Ambient BRDF

• For SH lighting– Diffuse lighting color is computed with a normal vector– Specular lighting color is computed with a reflection

vector• No specular cosine lobe is considered• Coarsely approximated

Page 32: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Color terms for Ambient BRDF

• For image based lighting– Diffuse lighting color is computed with

• Diffuse cube map• SH vector (computed from an environment map)

– Specular lighting color is computed with• Pre-filtered mipmapped environment map

Page 33: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Result - Ambient + Ambient BRDF

Page 34: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Comparison – Ambient BRDF

OFF ON

Page 35: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Comparison – Ambient BRDF

OFF ON

Page 36: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Performance

Ad-hoc model

Customized model

Anisotropic model

Spectral model

Metal model

Ashikhmin

Ambient BRDF off 3.13 3.71 4.67 4.02 3.48 5.15

Ambient BRDF on N/A 4.37 5.13 4.61 3.83 5.76

Unit : ms

Page 37: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Final comparison 1

Our physically based models Ad-hoc model

Page 38: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Final comparison 2

Our physically based models Ad-hoc model

Page 39: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Final comparison 3

Our physically based models Ad-hoc model

Page 40: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Conclusion

• A physically based model is– Easy to use for artists– Easy to get photo-realistic results– Reasonable to use in terms of performance

• Ambient shading improvement is important– Improvement is possible in real-time

Page 41: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Thanks to the following people

• R&D programmers:– Tatsuya Shoji, Bart Sekura and Elliott Davis

• Artists:– Kenichi Kanekura, Kazuki Shigeta, Kenichi Kaneko

and Ryo Mizukami

• Speakers for this course

Page 42: SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.

SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production

Thanks

htttp://research.tri-ace.com