I am searching on how baked lightmap system works.
I tried to bake 3 type of light : Baked indirect, subtractive and shadowmask.
Is it possible to load those texture with script?
For example, at trigger 1 the baked indirect will be loaded, at trigger 2 the subtractive will be loaded ( I am thinking of this because it can optimize some scenario).
I recall this is the needed code to load the lightmap
public void loadBakedTexture()
{
int length = lightingTextureDir.Length;
LightmapData[] lightMapList = new LightmapData[length];
for (int i = 0; i < length; i++)
{
LightmapData lightMap = new LightmapData();
lightMap.lightmapDir = lightingTextureDir[i];
lightMap.lightmapColor = lightingTextureLight[i];
lightMapList[i] = lightMap;
}
LightmapSettings.lightmaps = lightMapList;
Lightmapping.lightingDataAsset = lightingDataAsset;
}
I tried to load the texture and it somehow create saturation effect
Baked indirect
It is indeed possible to achieve what you need. The piece of the puzzle that you need is the additional data that is stored per light in Light.bakingOutput. Setting this value on your lights, from the bake matching the lightmaps that you’re setting, should make everything come together.
But I have more question, why can’t I delete the previous LightBakingOutput lightBakingOutput ?
I tried to call delete but it return error because it’s not an object.
Thank you again in advance
LightBakingOutput is a struct, and therefore not a typical unity object. It simply stores a very small amount of data about the result of the bake for the given light. There isn’t anything to delete, and simply assigning a new one to the light should be sufficient. Is this causing you any troubles?