Browse Source

accumulate all indirect diffuse sources and then apply a single diffuse indirect BRDF.

Ben Houston 9 years ago
parent
commit
28997aa732

+ 0 - 5
src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl

@@ -1,5 +0,0 @@
-#ifdef USE_LIGHTMAP
-
-	indirectReflectedLight.diffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
-
-#endif

+ 16 - 6
src/renderers/shaders/ShaderChunk/lights_template.glsl

@@ -40,19 +40,29 @@ GeometricContext geometry = GeometricContext( -vViewPosition, normalize( normal
 
 
 #endif
 #endif
 
 
+#if defined( BRDF_Material_DiffuseIndirectLight )
+
 	{
 	{
 	
 	
-		IncidentLight indirectLight = getAmbientIndirectLight( ambientLightColor, geometry );
+		IncidentLight indirectLight;
+		indirectLight.direction = geometry.normal;
+		indirectLight.color = ambientLightColor;
 
 
-		BRDF_Material_DiffuseIndirectLight( indirectLight, geometry, material, indirectReflectedLight );
+#ifdef USE_LIGHTMAP
 
 
-	}
+		indirectLight.color += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
+
+#endif
+
+#if ( MAX_HEMI_LIGHTS > 0 )
 
 
-#if ( MAX_HEMI_LIGHTS > 0 ) && defined( BRDF_Material_DiffuseIndirectLight )
+		for ( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
 
 
-	for ( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
+			indirectLight.color += getHemisphereIndirectLight( hemisphereLights[ i ], geometry ).color;
 
 
-		IncidentLight indirectLight = getHemisphereIndirectLight( hemisphereLights[ i ], geometry );
+		}
+
+#endif
 
 
 		BRDF_Material_DiffuseIndirectLight( indirectLight, geometry, material, indirectReflectedLight );
 		BRDF_Material_DiffuseIndirectLight( indirectLight, geometry, material, indirectReflectedLight );
 
 

+ 0 - 1
utils/build/includes/common.json

@@ -130,7 +130,6 @@
 	"src/renderers/shaders/ShaderChunk/fog_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/fog_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/lights_pars.glsl",
 	"src/renderers/shaders/ShaderChunk/lights_pars.glsl",
-	"src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl",
 	"src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl",
 	"src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl",
 	"src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl",