About lightmap, there is something strange

babylon’s lightmap seem’s very different with other engine.

By default the lightmap and the model’s color are added together to calculate the final color.
The ambient light and IBL both affect the model color but not the lightmap.

So if the IBL intensity (i.e. envirment intensity) is 0, only the lightmap color will be displayed.
I thought lightmap is an additive of the ambient light color would be more reasonable, like threejs dose. The object will be illuminated by the lightmap in black ambient light.

babylonjs:

// _____________________________ LightMappping _____________________________________
#ifdef LIGHTMAP
    #ifndef LIGHTMAPEXCLUDED
        #ifdef USELIGHTMAPASSHADOWMAP
            finalColor.rgb *= lightmapColor.rgb;
        #else
            finalColor.rgb += lightmapColor.rgb;
        #endif
    #endif
#endif

#define CUSTOM_FRAGMENT_BEFORE_FOG

threejs:

#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vUv2 );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometry.normal );
	#endif
#endif

Welcome aboard!

cc @sebavan

I think there have been some discussions about lightmaps and how to handle them before, but I can’t remember where…

Changing the default lightmap mode which controls this would break back compat hence why we kept our old additive (Spec + Diffuse) mode as the default.

1 Like