A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming...

61
A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Transcript of A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming...

Page 1: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

A simplified artist interface

Physically Based Shading

Niklas HanssonHead Teacher Game programming The Game Assembly.

Page 2: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Physically Based Shading

• What is it ?• Why should I use it ?• How do I integrate it into a project ?

Page 3: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Basic BRDF Theory• Boundary : When light goes from one material to another• Light splits up into two directions : reflection and refraction.• The amount of light

reflected depends on thematerials reflective index.

Image from “Real-Time Rendering 3rd Edition”

Page 4: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Basic BRDF Theory

• Basic Material- Part is Reflected- Part enters the material

• Metal-Part is Reflected-The part entering the Material is absorbed

Image from “Real-Time Rendering 3rd Edition”

Page 5: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Basic BRDF Theory

•Non metals- Light that enters the material scatters internally- Is absorbed- and often exits the surface again.

Image from “Real-Time Rendering 3rd Edition”

Page 6: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Basic BRDF Theory

• Sub surface scattering– Distance between enter and exit positions are

determined by the material.

Image from “Real-Time Rendering 3rd Edition”

Page 7: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Basic BRDF Theory

• Point model– By ignoring distance between exit and enter points

we can model lighting with an BRDF.

Image from “Real-Time Rendering 3rd Edition”

Page 8: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Basic Microfacet BRDF Theory

Image from “Real-Time Rendering 3rd Edition”

•Microfacets•A surface consists of many small perfectly flat surfaces.•How much they differ in normal determines how light interact

Page 9: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Basic Microfacet BRDF Theory

Images from “Real-Time Rendering 3rd Edition”

Page 10: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Shadowing & Masking

• Not all micro facets facing half vectors direction contribute to lightning

•Shadowing•Masking

Images from “Real-Time Rendering 3rd Edition”

Page 11: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

So why is specular so important ?

Images from “Everything is Shiny” by John Hable

Page 12: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

So why is specular so important ?

Images from “Everything is Shiny” by John Hable

Page 13: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

The Microfacet BRDF

Page 14: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Fresnel Reflectance

• Returns a Value from 0-1 in RGB– Fraction of light reflected from optically flat surface

given Light directon l and Half vector h

Page 15: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Fresnel Reflectance

• Depends on refraction index (in our terms the substance of the object) and the light angle.

Image from “Real-Time Rendering 3rd Edition”

Page 16: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Fresnel

Images from “Everything has Fresnel” by John Hable

Page 17: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Schlick’s Approximation

• Decently Accurate, uses F(0) the refractive index as input.– Which is our substance term.

Page 18: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Geometric term

•Gives a scalar value between 0 and 1• Contains the fraction of non obscured microfacets• Various functions exists most using roughness as input

Page 19: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Distribution function

• Calculates factor of microfacets reflecting light towards the eye

• The function determines size and shape of the specular highlight

Page 20: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Distribution Functions

• Blinn Phong Distribution Function

• Modified Blinn Phong

Page 21: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Beckman Distribution function

Conversion :

Page 22: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

• If the specular highlight is larger the specular intensity must be lower.

• N = roughness

Page 23: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

Page 24: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

Page 25: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

Page 26: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

Page 27: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

• 0.397436n+0.0856832

Page 28: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

• 0.397436n+0.03183

Page 29: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blinn Phong Energy Conversation

Page 30: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Energy Conversation

• Our Normalized equation for specular light

• Lambert

Cdiff*PI <=1• Full BRDF

Cdiff+Cspec <=1

Page 31: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Ambient Light

• Ambient Light is just Light– Has a specular component too

• reflections

• roughness controls reflections blurriness substance controls reflection strength.

• Pre blurred cubemaps

Page 32: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Ambient Light

• ATI cubemap gen has nice functions for preblurring mipmaps.– For correctnes the blurring needs to match your

specular light

Page 33: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Blurred cubemap

• Use the angular extent and always sample from top mip.• Use the glossiness for that mipmap level and evaluate max size of

highlight for size of angular extent.• Use the phong function to evaluate a contribution for all the pixels

inside the extent.

Page 34: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Why physically based ?

• It’s more realistic thanks to being physically based?

• Materials does not require as much retweaking under changing lighting conditions.

• You can create more easily varied materials with lesser number of values

• It saves artist time and simplifies workflow

Page 35: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Simplified Artist interface

• Reduces number of maps from 4-5 to 2.

• Simplifies Junior artist training– No longer take albedo and desaturate for intensity– And then lower color for gloss– We have all seen it

Page 36: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Simplified Artist interface

• PBL simplifies this by creating a material interface that makes sense. – Substance

• Is the index of refraction for the material• No need to hand paint.• Mathematically matches old intensity

Page 37: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Color picker

Page 38: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Simplified Artist interface

• Roughness– The old gloss– But thanks to Normalization a lot more useful– Where hand painting happens– Controls reflection blurrinees and spec – Surface Roughness that normal maps can’t show

– Touch– Observe

Page 39: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Example Material rusty Paint

Page 40: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Flexibillity

Page 41: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Sample Oskar stålberg

Page 42: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.
Page 43: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Why physically based ?

• Lower numbers of values to tweak

• Smaller tighter gbuffer– Low bandwitdh– Small ALU increase– Ideal for deferred rendering

• While still allowing very varied materials

Page 44: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

How to use it

• What did we do ?

• Microfacet BRDF with – Normalized Blinn Phong– Fresnel reflectance– Void Geometry Function

• G(h) = 4(n dot l)(n dot v)

– Prefiltered glossy reflections from cubemap probes– Ambient from ambient probes

Page 45: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

What we did

• Cref is the value from the reflection probe• Camb is the value from the ambient probe• Fschlick(v,h) is the fresnel term using the view direction instead of the light direction

Page 46: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Ambient vs reflection Energy Conversation

Page 47: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.
Page 48: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Lessons learned

• Substance and Roughness vs Intensity and Gloss– Spend time training and communicating to your

artists– Help them use the new interface

• Tools is essential– Beware of bugs

Page 49: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Maya plugin

Page 50: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.
Page 51: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

What we did

• Flexible• Kind of projects

–Space shooter–Realtime Strategy –First Person shooter

Page 52: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Space shooter

Page 53: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.
Page 54: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Fps project

• Goals– Resolve all issues found during the last project– Get an easy to light solution that took little rebuild

time and would work with just a few spot lights.

• Techniques– All enviroment and ambient probes generated by the

ingame engine to achieve consistency.– Box projected cubemaps was used for reflections and

a variation was used for ambient– Simple Multi bounce solution for lightning

Page 55: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.
Page 56: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Occlusion

• Specular and reflection doing more work– Will look weird in areas normally don’t reach by much

light

• Use Ambient occlusion– Multiply to spec– Multiply to reflection

• If needed add special Specular occlusion

Page 57: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

ReferencesSébastien Lagarde ”Adopting a physically based shading model “,”Feeding a physically

based shading model”

Roy Driscol “Energy Conversation In Games”

Fabien Giesen “Blinn-Phong normalization factor”

Nathaniel Hoff mann, “Crafting Physically Moti vated Shading Models for Game Devel op ment”, SIGGRAPH 2010

Dim i tar Lazarov, “Physically- based lighting in Call of Duty: Black Ops” SIGGRAPH 2011

Chris ti an Schüler, “An Efficient and Physically Plausible Real- Time Shad ing Model.” ,” The Blinn- Phong Normalization Zoo”

Akienne- Möller, Haines and Hoff mann, “Real- Time Rendering” book

Yoshiharu Gotanda, “Practical Implementation of Physically- Based Shading Models at tri- Ace”, SIGGRAPH 2010

Yoshiharu Gotanda, “Practical Physically Based Rendering in Real-time”, SIGGRAPH 2012

Page 58: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Going forward

• Testing on real projects

• Better Geometry term

• Using the proper mipmapping for cubemaps

• Some kind of Diffuse- specular energy conversation

Page 59: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

Physically based for non realistic rendering

• Can we do it ?– Yes just a material interface– Rules can be bent and broken.

• Specular not that important for cartoonish look– Diffuse light ,albedo,normal,AO more important

Page 60: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

RTS game

Page 61: A simplified artist interface Physically Based Shading Niklas Hansson Head Teacher Game programming The Game Assembly.

More non photo