소스 검색

ensure that indirect sheen is shadowed by specular ambient occlusion. (#26940)

* ensure that indirect sheen is shadowed by specular ambient occlusion.

* switch from specularOcclusion to ambientOcclusion
Ben Houston 1 년 전
부모
커밋
9113c0476d

+ 4 - 0
src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js

@@ -6,6 +6,10 @@ export default /* glsl */`
 
 
 	reflectedLight.indirectDiffuse *= ambientOcclusion;
 	reflectedLight.indirectDiffuse *= ambientOcclusion;
 
 
+	#if defined( USE_SHEEN ) 
+		sheenSpecularIndirect *= ambientOcclusion;
+	#endif
+
 	#if defined( USE_ENVMAP ) && defined( STANDARD )
 	#if defined( USE_ENVMAP ) && defined( STANDARD )
 
 
 		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
 		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );

+ 5 - 3
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js

@@ -50,7 +50,9 @@ struct PhysicalMaterial {
 
 
 // temporary
 // temporary
 vec3 clearcoatSpecular = vec3( 0.0 );
 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 ) {
 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 );
     float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
@@ -491,7 +493,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome
 
 
 	#ifdef USE_SHEEN
 	#ifdef USE_SHEEN
 
 
-		sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
+		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
 
 
 	#endif
 	#endif
 
 
@@ -516,7 +518,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
 
 
 	#ifdef USE_SHEEN
 	#ifdef USE_SHEEN
 
 
-		sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
+		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
 
 
 	#endif
 	#endif
 
 

+ 1 - 1
src/renderers/shaders/ShaderLib/meshphysical.glsl.js

@@ -197,7 +197,7 @@ void main() {
 		// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
 		// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
 		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
 		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
 
 
-		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
+		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
 
 
 	#endif
 	#endif