Skip to content

Commit

Permalink
ensure that indirect sheen is shadowed by specular ambient occlusion.
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
  • Loading branch information
bhouston committed Oct 11, 2023
1 parent b9c56f2 commit d382f44
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ export default /* glsl */`
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
reflectedLight.indirectSpecular *= specularOcclusion;
#if defined( USE_SHEEN )
sheenSpecularIndirect *= specularOcclusion;
#endif
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ struct PhysicalMaterial {
// temporary
vec3 clearcoatSpecular = vec3( 0.0 );
vec3 sheenSpecular = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
Expand Down Expand Up @@ -441,7 +443,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
#ifdef USE_SHEEN
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
#endif
Expand All @@ -466,7 +468,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
#ifdef USE_SHEEN
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shaders/ShaderLib/meshphysical.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void main() {
// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
#endif
Expand Down

0 comments on commit d382f44

Please sign in to comment.