Page 1 of 1

Unreal Level file content - reverse engineering

Posted: 20 Jul 2020, 17:46
by jammer64
Has anyone tried to disassemble unr file to check where are actors, where's lightmap stuff etc.? I wonder if, for example, lightmaps could be replaced with externally calculated ones, having nice baked global illumination, smooth edges and stuff :)

Re: Unreal Level file content - reverse engineering

Posted: 20 Jul 2020, 20:14
by yrex
Has anyone tried to disassemble unr file to check where are actors, where's lightmap stuff etc.?

Yes.

I wonder if, for example, lightmaps could be replaced with externally calculated ones, having nice baked global illumination, smooth edges

No. Lightmaps aren't stored as ordinary textures, but as one-bit "hits/doesn't hit" data per each light. This also allows dynamic non-moving lights to have shadows. At best, you could fuzz the borders and hope they look good after Unreal smooths them.

Re: Unreal Level file content - reverse engineering

Posted: 13 Aug 2020, 14:43
by jammer64
That's actually very interesting! So how are lightmaps generated? Engine bakes them in runtime before level shows up, just using masking data from file?

I've just peeked into map file in hex viewer. I guess I see which data portion is lightmap but it seems to display different values than $00/$FF from time to time. Isn't the mask 8bit grayscale by any chance? Unless one byte is just a combination of up to 8 lights on/off per texel.

Re: Unreal Level file content - reverse engineering

Posted: 13 Aug 2020, 18:20
by yrex
You can observe when lightmaps are generated by doing something like "set light lightbrightness/hue/saturation <number>" and walking around until you see the changes. I think this happens after PreBeginPlay. You can also do "flush" to update all lightmaps. UsePrecache may also affect this somehow.

No, one byte stores 8 texels, although these masks are blurred on runtime, creating grayscale images.