mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-17 14:48:46 +02:00
Normalized diffuse & specular of directional, point and spot lights such as a light intensity of 1 gives a perpendicular diffuse lighting of the same color as the albedo for dielectric materials.
This commit is contained in:
parent
2e4fc5e58c
commit
12c48a38f7
1 changed files with 10 additions and 10 deletions
|
@ -186,7 +186,7 @@ float specularDistribution(SurfaceData surface) {
|
||||||
// Add geometric factors G1(n,l) and G1(n,v)
|
// Add geometric factors G1(n,l) and G1(n,v)
|
||||||
float smithInvG1NdotL = evalSmithInvG1(surface.roughness4, surface.ndotl);
|
float smithInvG1NdotL = evalSmithInvG1(surface.roughness4, surface.ndotl);
|
||||||
denom *= surface.smithInvG1NdotV * smithInvG1NdotL;
|
denom *= surface.smithInvG1NdotV * smithInvG1NdotL;
|
||||||
// Don't divide by PI as it will be done later
|
// Don't divide by PI as this is part of the light normalization factor
|
||||||
float power = surface.roughness4 / denom;
|
float power = surface.roughness4 / denom;
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
|
@ -202,12 +202,11 @@ vec4 evalPBRShading(float metallic, vec3 fresnel, SurfaceData surface) {
|
||||||
vec3 specular = fresnelColor * power * angleAttenuation;
|
vec3 specular = fresnelColor * power * angleAttenuation;
|
||||||
float diffuse = (1.0 - metallic) * angleAttenuation * (1.0 - fresnelColor.x);
|
float diffuse = (1.0 - metallic) * angleAttenuation * (1.0 - fresnelColor.x);
|
||||||
|
|
||||||
diffuse /= 3.1415926;
|
// We don't divided by PI, as the "normalized" equations state we should, because we decide, as Naty Hoffman, that
|
||||||
// Diffuse is divided by PI but specular isn't because an infinitesimal volume light source
|
// we wish to have a similar color as raw albedo on a perfectly diffuse surface perpendicularly lit
|
||||||
// has a multiplier of PI, says Naty Hoffman.
|
// by a white light of intensity 1. But this is an arbitrary normalization of what light intensity "means".
|
||||||
// (see http://blog.selfshadow.com/publications/s2013-shading-course/hoffman/s2013_pbs_physics_math_notes.pdf
|
// (see http://blog.selfshadow.com/publications/s2013-shading-course/hoffman/s2013_pbs_physics_math_notes.pdf
|
||||||
// page 23 paragraph "Punctual light sources")
|
// page 23 paragraph "Punctual light sources")
|
||||||
|
|
||||||
return vec4(specular, diffuse);
|
return vec4(specular, diffuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,9 +221,9 @@ vec4 evalPBRShadingDielectric(SurfaceData surface, float fresnel) {
|
||||||
vec3 specular = vec3(fresnelScalar) * power * angleAttenuation;
|
vec3 specular = vec3(fresnelScalar) * power * angleAttenuation;
|
||||||
float diffuse = angleAttenuation * (1.0 - fresnelScalar);
|
float diffuse = angleAttenuation * (1.0 - fresnelScalar);
|
||||||
|
|
||||||
diffuse /= 3.1415926;
|
// We don't divided by PI, as the "normalized" equations state we should, because we decide, as Naty Hoffman, that
|
||||||
// Diffuse is divided by PI but specular isn't because an infinitesimal volume light source
|
// we wish to have a similar color as raw albedo on a perfectly diffuse surface perpendicularly lit
|
||||||
// has a multiplier of PI, says Naty Hoffman.
|
// by a white light of intensity 1. But this is an arbitrary normalization of what light intensity "means".
|
||||||
// (see http://blog.selfshadow.com/publications/s2013-shading-course/hoffman/s2013_pbs_physics_math_notes.pdf
|
// (see http://blog.selfshadow.com/publications/s2013-shading-course/hoffman/s2013_pbs_physics_math_notes.pdf
|
||||||
// page 23 paragraph "Punctual light sources")
|
// page 23 paragraph "Punctual light sources")
|
||||||
return vec4(specular, diffuse);
|
return vec4(specular, diffuse);
|
||||||
|
@ -239,8 +238,9 @@ vec4 evalPBRShadingMetallic(SurfaceData surface, vec3 fresnel) {
|
||||||
float power = specularDistribution(surface);
|
float power = specularDistribution(surface);
|
||||||
vec3 specular = fresnelColor * power * angleAttenuation;
|
vec3 specular = fresnelColor * power * angleAttenuation;
|
||||||
|
|
||||||
// Specular isn't divided by PI because an infinitesimal volume light source
|
// We don't divided by PI, as the "normalized" equations state we should, because we decide, as Naty Hoffman, that
|
||||||
// has a multiplier of PI, says Naty Hoffman.
|
// we wish to have a similar color as raw albedo on a perfectly diffuse surface perpendicularly lit
|
||||||
|
// by a white light of intensity 1. But this is an arbitrary normalization of what light intensity "means".
|
||||||
// (see http://blog.selfshadow.com/publications/s2013-shading-course/hoffman/s2013_pbs_physics_math_notes.pdf
|
// (see http://blog.selfshadow.com/publications/s2013-shading-course/hoffman/s2013_pbs_physics_math_notes.pdf
|
||||||
// page 23 paragraph "Punctual light sources")
|
// page 23 paragraph "Punctual light sources")
|
||||||
return vec4(specular, 0.f);
|
return vec4(specular, 0.f);
|
||||||
|
|
Loading…
Reference in a new issue