Bläddra i källkod

Merge pull request #17359 from WestLangley/dev_ibl_irradiance

Shaders: decouple light probe irradiance from other indirect light sources
Mr.doob 6 år sedan
förälder
incheckning
cc942a7751

+ 1 - 1
src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js

@@ -7,7 +7,7 @@ export default /* glsl */`
 
 
 #if defined( RE_IndirectSpecular )
 #if defined( RE_IndirectSpecular )
 
 
-	RE_IndirectSpecular( radiance, irradiance, clearcoatRadiance, geometry, material, reflectedLight );
+	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
 
 
 #endif
 #endif
 `;
 `;

+ 3 - 1
src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js

@@ -15,9 +15,11 @@ export default /* glsl */`
 
 
 	#endif
 	#endif
 
 
+	vec3 iblIrradiance = vec3( 0.0 );
+
 	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
 	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
 
 
-		irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );
+		iblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );
 
 
 	#endif
 	#endif
 
 

+ 1 - 0
src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js

@@ -117,6 +117,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC
 
 
 void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
 void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
 
 
+	reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );
 
 
 }
 }