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.

Re: Unreal Level file content - reverse engineering

Posted: 14 Aug 2020, 18:16
by jammer64
I know that 'flush' updates all lights but I didn't know the command for specific lights ;) Thanks, that was very insightful! Did you use this file research in any particular project? Is map format breakdown published anywhere? :)

Re: Unreal Level file content - reverse engineering

Posted: 15 Aug 2020, 16:43
by yrex
Yes, some time ago, I wrote a program which after taking tons of shortcuts and cutting tons of corners could approximate the experience of playing Unreal maps.

Here's a partial specification of the format:

http://utgl.unrealadmin.org/UT_Package_ ... at_pdf.zip

But it doesn't mention level-related structures like the BSP tree or lightmaps. To get that, visit the other link and look into the source code.

Re: Unreal Level file content - reverse engineering

Posted: 18 Aug 2020, 12:25
by jammer64
Thanks a lot! <3