Main
Tutorials











 

Map Optimization Super Tweaks

Cull Distance

Sometimes, no matter how much you try to optimize, some static meshes will refuse to cooperate, and will be visible from great distances in wireframe mode even if the player is nowhere near it or the zone it is in. In cases like these we can use Cull Distances to hide the mesh. First we have to measure the furthest distance we can see the mesh from. For this there is a convenient measuring tool in UEd that we can use. If we hold down Shift and the middle mouse button, we can measure distances in UEd. Starting at a mesh and going to the farthest possible point we can see it from, we can get an idea what value we need to use for the Cull Distance.



Care must be taken when doing this, you must make sure that there are no farther points that you can see the mesh from, otherwise it will suddenly pop into view at that point. My measurement for that mesh is about 1032 to the farthest point along the wall, so to be safe we'll round it off to 1100. Open up the mesh properties and set that value in Display >> CullDistance.



The default value is 0, which tells the engine not to use cull distances for the mesh. Also keep in mind that cull distances work even inside the editor, and even in the 2d viewports! Pay close attention to which meshes you use this on so you don't lose track of them. Let's take a look at a mesh with a Cull Distance set in the editor.



Lightmaps

Lightmaps are among the lesser known techniques for map optimization, and mainly have an effect on the file size and hence the download time and time it takes the game to load it. Optimizing lightmaps has a dramatic effect on filesize, as I will demonstrate.

Lightmaps are how the engine stores lighting information for BSP. The lighting information for BSP surfaces are stored in textures internal to the map, and are not normally visible in the editor. Multiple surfaces are combined onto each texture. Being textures, this information takes up space, but there is a way to change how much space it takes, and it can be altered per surface to optimize our map's size. The main value that we can change to alter this is the Lightmap value in Surface Properties.



This value is literally the "grid" where lighting values are taken, the default being 32. The lower this value, the closer together the "grid points" are and thus the sharper the detail on shadows. Values lower than 4 have little noticeable effect on shadow detail and should not be used. Higher values give less shadow detail, but lower the lightmap sizes and thus the overall file size. Surfaces that the player will never see should be set to Unlit or Fake Backdrop so that there is no lightmap for them and they don't unnecessarily increase the map's size.

There is one other value that we can change for lightmaps, the texture compression in the Build Settings.





The default is DXT3, but this can be changed to RGB8 (Smaller size) or DXT1 (Higher compression = Smallest size).

To show the effect that changing the lightmap values have, I will be using DM-DE-Ironic as a test, since it has areas of high shadow detail. A lot of the floors in the level have had the lightmap value raised to 4, giving sharper detail but increasing the filesize. Here is a pic of the original unaltered level:





You can see the sharp detail on the shadows on the floor and up the wall toward the vines. Let's start by changing the compression of the lightmaps and see what effect that has on the shadows and the file size. In this next pic I have changed the Build Setting to DXT1 for highest compression.





As you can see, the only noticeable difference is the Lightning Gun ammo pickup is darker. Using this compression method, we've already lowered the map's size by 1.1MB! In this next pic, instead of changing the compression of the lightmaps, I've set all the surfaces back to the default lightmap value of 32. Remember that a lot of the floors and walls were set at 4 to get the details on the shadows. Let's see what changed.





This time there is a drastic change in both the detail and the file size. The map size has been reduced almost by a third, but the sharp detail on the shadows is gone and seams have appeared at the edges of side-by-side brushes. This can be prevented by laying out the brushes differently to prevent them from being side-by-side, using different textures on them, or by adding either brushes or meshes for trim.

The file size reduction seen by that method illustrates why raising the lightmap value to increase shadow detail should be used sparingly, if used on all surfaces it will make your map enormous without giving any benefit in areas where there are no sharp details on shadows. In this next pic I have lowered the lightmap value for all surfaces to 256. Let's see what happens.





The file size has been lowered an additional 700KB, but now all shadow detail is completely gone, and the seams at BSP edges are much more pronounced. Lowering the lightmap value to 256 should only be used in areas where there is a complete lack of need for shadow detail, but as you can see there is at least SOME benefit to doing this, even if it is small. For optimization, every little bit counts. It would also be possible to create all of the shadow detail using Projectors, which would get rid of the need for using higher lightmap values and increasing the map size.

In this last pic, I have left all of the lightmaps at 256 and in addition set the compression to DXT1.





We've lowered the file size almost an additional 200KB, with no noticeable difference from the DXT3 compression except for once again making the ammo pickup darker. In total we've lowered the file size 40% but have completely destroyed our shadow detail. The lighting in the level would have to be redone and projectors used to get the shadows back, which would increase the file size again, but it would still be less than what it originally was. Keeping in mind the lightmap sizes as you create a level will help you in optimizing your map and getting it to load faster, and let people download it faster.

That's it for this tutorial! In general, the most helpful piece of advice for map optimization is don't overload your level with meshes or have it so open that no optimization is possible. Keep optimization in mind as you are making the level and everything should already be running smoothly at the end with little effort on your part. If not, then these techniques will certainly come in handy. Good luck!

Back To Tutorials