Editing Lightmaps At Edit Time

Hi all,

I’ve written an editor script which edits one of the beast lightmaps, colouring an object red in the lightmap.

To colour the object it uses:

LightmapSettings.lightmaps[lightmapIndex].lightmapFar.SetPixel((int)x, (int)y, Color.red);

Then applies the texture with:


This works great, the object is now red and in the lightmap preview it’s clearly red too.

However as soon as I hit save, the lightmap reverts to how it was baked by Beast. Any idea on how I commit these changes onto the actual .exr file in Unity?

It turns out, that Unity can only import EXR files, it cannot save changes made to them. You should look for an external imaging library that allows to import/export EXR.