Skip to content
Snippets Groups Projects
Commit 5dcb84d1 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Multiscatter IBL

parent 0ca08ee2
No related branches found
No related tags found
No related merge requests found
...@@ -375,6 +375,12 @@ vec2 BRDF(float NoV, float roughness) ...@@ -375,6 +375,12 @@ vec2 BRDF(float NoV, float roughness)
return texture(brdfLut, vec2(NoV, roughness)).rg; return texture(brdfLut, vec2(NoV, roughness)).rg;
} }
// Lagarde and de Rousiers 2014, "Moving Frostbite to PBR"
float computeSpecularAO(float NoV, float ao, float roughness)
{
return clamp(pow(NoV + ao, exp2(-16.0 * roughness - 1.0)) - 1.0 + ao, 0.0, 1.0);
}
// set colorDiffuse and colorSpec to the results of GLTF PBR style IBL // set colorDiffuse and colorSpec to the results of GLTF PBR style IBL
vec3 pbrIbl(vec3 diffuseColor, vec3 pbrIbl(vec3 diffuseColor,
vec3 specularColor, vec3 specularColor,
...@@ -386,16 +392,20 @@ vec3 pbrIbl(vec3 diffuseColor, ...@@ -386,16 +392,20 @@ vec3 pbrIbl(vec3 diffuseColor,
out vec3 specContrib) out vec3 specContrib)
{ {
// retrieve a scale and bias to F0. See [1], Figure 3 // retrieve a scale and bias to F0. See [1], Figure 3
vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0-perceptualRough); vec2 brdf = BRDF(clamp(nv, 0, 1), 1.0-perceptualRough);
vec3 diffuseLight = irradiance; vec3 diffuseLight = irradiance;
vec3 specularLight = radiance; vec3 specularLight = radiance;
vec3 diffuse = diffuseLight * diffuseColor; vec3 energy = mix(brdf.xxx, brdf.yyy, specularColor);
vec3 specular = specularLight * (specularColor * brdf.x + brdf.y);
vec3 diffuse = diffuseLight * diffuseColor * (1.0 - energy);
vec3 specular = specularLight * energy;
specular *= computeSpecularAO(nv, ao, perceptualRough * perceptualRough) * (1.0 + specularColor * (1.0 / brdf.y - 1.0));
specContrib = specular * ao; specContrib = specular;
return (diffuse + specular) * ao; return (diffuse * ao) + specular;
} }
vec3 pbrIbl(vec3 diffuseColor, vec3 pbrIbl(vec3 diffuseColor,
......
...@@ -129,7 +129,7 @@ vec2 BRDF(float NoV, float roughness) ...@@ -129,7 +129,7 @@ vec2 BRDF(float NoV, float roughness)
float G = G_SchlicksmithGGX(dotNL, dotNV, roughness); float G = G_SchlicksmithGGX(dotNL, dotNV, roughness);
float G_Vis = (G * dotVH) / (dotNH * dotNV); float G_Vis = (G * dotVH) / (dotNH * dotNV);
float Fc = pow(1.0 - dotVH, 5.0); float Fc = pow(1.0 - dotVH, 5.0);
LUT += vec2((1.0 - Fc) * G_Vis, Fc * G_Vis); LUT += vec2(Fc * G_Vis, G_Vis);
} }
} }
return LUT / float(NUM_SAMPLES); return LUT / float(NUM_SAMPLES);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment