What is the "rebalancing coefficient" when decoding directional lightmap(5.4&5.3)?

Hi guys!
I’m doing some reserch about decoding and encoding directional lightmaps.And then find this when decoding directional lightmap:

inline half3 DecodeDirectionalLightmap (half3 color, fixed4 dirTex, half3 normalWorld)
{
// In directional (non-specular) mode Enlighten bakes dominant light direction
// in a way, that using it for half Lambert and then dividing by a “rebalancing coefficient”
// gives a result close to plain diffuse response lightmaps, but normalmapped.

// Note that dir is not unit length on purpose. Its length is “directionality”, like
// for the directional specular lightmaps.

half halfLambert = dot(normalWorld, dirTex.xyz - 0.5) + 0.5;

return color * halfLambert / max(1e-4h, dirTex.w);
}

It seems that unity divding a"rebalancing coefficient" (max(1e-4h, dirTex.w)) when decoding,But what excactly the “dirTex.w” means? Can i calculate this factor myself instead of sampling another texture(DirTex)?

You can’t calculate it yourself, it’s part of the texture. It doesn’t require sampling another texture, since it’s in the same texture as the rest of the directional lighting.

3Q~
I found some documents about enlighten that talk about this factor.It seem that the factor(dirTex.w) means "
how much light in the first lightmap is the result of light coming in along the dominant direction",and that I tried to calculate this factor with atten of main light in my customed shaders.Although there’s some diffrerent bewtween mine and the original one, It looks the same in most time.

1 Like

Hello there! May I ask were you find this documentation? I’m exploring the possibility to bake directional lightmaps in vray.