PBR: Real-time Implementation Site du cours
Before we start Comment on genere une image ?
On a vu le raytracing
On a vu la rasterization
On va se focus sur le temps reel avec de la rasterization
Old Times Lambert
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
On a tous fait un Lambert model
Plus l'angle est eleve entre la normal et la lumiere, moins il n'y a d'energie
Il n'y a pas de modele
diffus
En une seule operation on a notre BRDF
Il existe d'autres modeles mais la difference visuelle n'est pas assez bonne pour etre utilises
Phong
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Approximation pas tres bonne
MAIS precurseur a son epoque (
)
Pas de conservation d'energie:
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Pseudocode Lambert
void main()
{
vec3 diffuse = kD * dot(normal, lightDirection) * color;
gl_FragColor.rgba = vec4(diffuse, 1.0 );
}
Phong
void main()
{
vec3 r = reflect(- viewDirection, normal);
vec3 diffuse = kD * dot(normal, lightDirection) * color;
vec3 specular = kS * pow(max(dot(lightDirection, r)), exponent);
gl_FragColor.rgba = vec4(diffuse + specular, 1.0 );
}
What and why Introduction
Non-physical model requires a lot of tweaking
Si on a un artiste qui fait une scene en exterieur puis on lui dit qu'on doit aller dans un tunnel en voiture, l'artiste pleure
Il doit tweaker les materiaux pour que ca ait l'air joli en fonction de la lumiere
C'est pour ca qu'il y a eu l'avenement du Real Time Rendering vers 2013
C'est dur de definir le PBR
Definition: PBR
Modele mathematiques et approximations que nous allons tous suivre pour decrire les interactions entre la lumiere et la matiere
What is PBR ?
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Pourquoi c'est populaire ?
Decrit le monde plus precisement, donne des rendus realistes
Tout le monde utilise plus ou moins les memes inputs
Moins de tweaking
Win-win pour les ingenieurs et artistes
Microfacets Theory
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Ce modele approxime ce qu'il se passe dans la vraie vie
On dit que tous les materiaux sont composes de miroirs plus ou moins alignes
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
C'est quoi la difference entre un miroir et un plastique ?
Notre premier cas sera un miroir
Le second est un materiaux super diffus
Dielectrics vs Conductors
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Conductors
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
La couleur diffuse serait une approximation du sub-surface scattering
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Les conducteurs reflete
de la lumiere
Les metaux n'ont pas de sub-surface scattering
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Les conducteurs refletent
de la lumiere
Certains conducteurs ont leur couleur propre due aux longueurs d'ondes absorbees
BRDF BRDF Simplification
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Notre BRDF devient pulg & play
On peut remplacer par ce qu'on veut du moment que
Implementation notes
Diffuse Lobe
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Specular Lobe
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Specular BRDF
Normal distribution function
Estimates the area of microfacets aligned to give perfect specular
As usual, lots of different NDF equations …
To be consistent, let's implement the Trowbridge-Reitz equation
Low roughness means few samples contributing a lot to specular
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Shadowing term
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
On va approximer
Approximation de l'occlusion
L'orientation des facettes peut pieger la lumiere
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Effet Fresnel
On a un joli coucher de soleil sur la mer (ou ocean)
L'eau est un miroir modulo les vagues
Pour tout materiaux, la reflectance va etre maximale aux angles rasants
L'effet Fresnel c'est le poids du specular lobe
: base reflectivity at normal incidence
: base reflectivity at grazing angle
Almost always 1 for conductors
Fresnel reflectance for common materials
For dialectics,
is often approximated with
Some materials
are tainted (gold, copper)
Implementation note:
For dielectics, pick
For conductors, store
in albedo texture
Use metallic input to lerp between the 2
Demo !
Direct-Lightning pseudocode
vec3 radiance = vec3(0 .0 );
for (int i = 0 ; i < NB_LIGHTS; + + i)
{
vec3 w_i = lights[i].direction;
vec3 kS = FresnelShlick(f0, wi, w_o);
vec3 specularBRDFEval = kS * f_s(p, w_i, w_o);
vec3 diffuseBRDFEval = (1.0 - kS) * f_d(p, w_i, w_o);
radiance + = (diffuseBRDFEval + specularBRDFEval) * sampleLight(lights[i], p, w_i) * dot(normal, w_i);
}
Textures
Les artistes font plusieurs textures
To remember !
Diffuse is an approximation of sub-surface scattering
La plupart des moteurs connus vont avoir des metallics workflow
Ca simplifie beaucoup la vie
Ponctual light Point light
Infinitely small
Isotropic
Describe only by a position
Simple to code and fast to sample
Power unit should be set using Lumens
How to select a proper value ?
Not as accurate as Area Light
Cette lumiere n'existe pas dans la vraie vie
Note
On ne va pas parler de directionnal light (deja fait)
Si on utilise une directionnal light, il faudra tweaker les parametres
Ce n'est pas aussi fidele que les Area lights
Image Based Lightning
IBL Diffuse
Mais c'est juste un flou gaussien ?
C'est pas si faux que ca, c'est assez proche
Il faut faire une integration par angle solide, et c'est complique.
Utilisation des coordonnees spheriques pour l'integration
Discretiser l'integrale avec la somme de Riemann
Calculer pour chaque texel, avec la direction
du centre
IBL Specular
Ca a ete teste et ca marche: c'est ca la 3D
Changer le niveau de roughness c'est faire du downsampling, pourquoi par appliquer la roughness en faisant des images de plus en plus petites
Pre-computed BRDF
Obtained bu substituting Fresnel Shlick
Only 2 inputs left: roughness, viewing angle
At runtime:
Fetch pre-integrated BRDF texture
Fetch convoluted environment
Apply the above equation to get the full specular component
Specular: compisistion
c2 brdf = GetIntegratedBRDF(NdotV, roughness);
vec3 prefilteredSpecular = GetPrefilteredSpecular((NdotV, roughness);
vec3 specular = prefilteredSpecular * (F * brdf.x + brdf.y);
To remember
C'est juste du pre-filtering
Colorspace and color precision
sRGB vs Linear
Monitors apply pow function to luminance
Toute l'industrie a du se base sur les ecran qui font ca donc ils ont cree le
Sur photoshop, une image sera encodee en sRGB pour retrouver les couleurs imaginees
On va eviter de faire nos calculs en sRGB
Soit on fait tout en sRGB
Soit on fait tout en lineaire
OUI
On applique a la fin la fonction sRGB pour convertir en lineaire
HDR vs LDR
Reinhard Tonemapping:
HDR has larger range of values
Units will create radiance color outside the
range
Perform computation in HDR, tonemap to LDR is required
HDR is required to get correct PBR result
Especially important for IBL
Going further Advanced materials
Examples: hair, skin, cloud, etc.