Generating LOD Data for Custom Worldspaces in Fallout 3 (WIP)

  1. World LOD Dialog
  2. LOD Landscape Meshes
  3. LOD Landscape Textures
  4. LOD Objects
  5. LOD Trees
  6. Regenerating LOD
  7. Packaging LOD
  8. Regenerating Wasteland LOD
  9. Troubleshooting

This tutorial will show you how to generate Level of Detail data in the G.E.C.K. (Garden of Eden Creation Kit). LOD stands for Level of Detail, which is a technique which game engines use to optimize gameplay. The basic concept is simple: when the player is close to an object in-game, the game engine uses a high polygon count model and high resolution texture for maximum visual quality; when the player moves away from the object, the engine replaces this model and texture with a lower polygon count model and lower resolution texture. By reducing the visual quality of the object, it can reduce the processing overhead on the system and improve framerate and/or render more objects on-screen at the same time.

LOD techniques differ from game to game, but most 3D games use some form of LOD optimization. In Fallout 3 and Oblivion, LOD is used in 4 principle areas:

In order to generate proper LOD for your mod, you must generate each of these four types of data. LOD generation is not complicated, but it is time consuming and suffers from certain limitations which will be discussed below.

Tip: Do Trial Runs I highly recommend that you experiment with the LOD generation process on a test mod before attempting it with your active mod. Going through the process a couple of times will give you a better understanding of how it works and help you to avoid some of the headaches and stress that can result from a fear of causing permanent damage to a mod you have put a lot of time and effort into. When you understand the process, you will be able to quickly identify and resolve any mistakes you might have made in its execution. This separates the procedural errors from the technical limitations of the process. LOD generation problems can be very confusing if you have made user errors and run into Geck-related limitations at the same time and you don't understand the difference between them.

The World LOD Dialog

The World LOD dialog in the Geck

All of the LOD functions for Fallout 3 can be found by selecting World -> World LOD... from the menu bar. This will pull up the World LOD dialog.

The World LOD dialog is very easy to use. First, select the world space that you would like to generate LOD for from the column on the left. Details about the world space, including the number of cells contained within it, and the number of 'chunks' that will be generated appear in the small information box to the right. (Unfortunately, for some reason, the display box is not large enough to display all of the information.)

Land Mesh Detail Adjust: I haven't figured out how (or if) the Land Mesh Detail Adjust works, but it appears to allow you to adjust the amount of detail (resolution) to use for generated meshes. I'll have to experiment with this function more to see if I can get it to do anything. This may reduce generation time by reducing the quality of the generated meshes.

The first button, Generate Terrain Meshes, is used to generate the landscape LOD meshes. This is the time and cpu-intensive process that seems to thwart a lot of people.

The next three buttons are used for generating the textures. Generate Terrain Textures is the button used for default terrain texture generation, and is the only option I will be covering in this tutorial (since I haven't tested the others).

The Chop Handpainted Terrain Texture button, according to the wiki, allows you to 'build LOD terrain texture maps from a handpainted texture up to 8192x8192 in size'. It's not clear whether these maps represent individual chunks, or if the map itself is subdivided to cover the entire terrain, although it seems to imply the latter.

The Combine Generated and Handpainted Terrain Textures button seems to imply that you can mix handpainted texture chunks with generated texture chunks, but the wiki has no information about this so that's pure speculation. Just one more thing I'll next to experiment with. :)

The next button, Generate Objects, is used to generate the visible while distant objects populating your landscape. Visible While Distant (or VWD) objects are low-poly versions of things like the Washington Monument, overpasses, radio towers, etc. They sit on top of the landscape LOD meshes, and, like the LOD landscape meshes, are replaced with the original, high-poly versions when you get close to them.

The last button is Generate Trees, which, predictably, generates tree LOD objects. Trees include 'real' trees (speedtree files) and 'fake' or static trees with the Has Tree LOD box checked in the Object dialog. (Needs to be verified.)

Generating LOD Landscape Meshes

The first stage of the LOD process is by far the most time-consuming and resource intensive. LOD landscape meshes are reduced polygon count copies of groups (or 'chunks') of the original landscape mesh (the terrain that you create in the heightmap editor and/or landscape editor). The process used to create the LOD meshes is known as 'decimation'. Decimation takes a high-poly mesh (in this case, the landscape) and approximates its shape using fewer polygons. Fallout 3 uses a multi-tiered system of landscape LOD that chunks groups of cells into 4x4, 8x8, 16x16 and 32x32 cell squares. The LOD meshes in each tier cover progressively larger surface areas, but at a reduced resolution. Using this process, an 8x8 LOD chunk will have less accuracy than a 4x4 chunk but render just as quickly. (If you look in the Data/Meshes/Landscape/LOD/Wasteland/ folder you will see that each chunk is approximately the same size even though they cover different surface areas.) The details that are lost in the decimation process are generally not noticeable at the distance from which the player views the mesh. (This technique is known as Discrete LOD. You can find a good article about LOD at Wikipedia.)

This improved LOD process comes at a cost, however: each LOD landscape mesh generation pass is expensive in terms of system resources and generation time, so the larger your landscape, the longer it's going to take to generate LOD for it. In fact, each pass is an order of magnitude more expensive: a small worldspace that only requires a few 'chunks' can be generated in minutes; a large worldspace requiring hundreds of chunks can take days or weeks and may not even be possible to generate on your system. (Many people with older systems have tried--and failed--to regenerate the Wasteland LOD data.) If your world space is very small (such that from every point in the world space every other cell is less than eight cells away) the Geck will only require a single decimation pass and the LOD folder will only contain 4x4 chunks. Once you exceed this size, an additional generation pass is required to generate 8x8 chunks. If your world space is greater than 15 cells across, a third pass will be required to generate 16x16 chunks, etc. Although this system might seem complicated and expensive in terms of generation time, it allows the game to maintain high visual fidelity without a significant loss of framerate. Anyone who's played Oblivion will immediately notice the difference in quality between Oblivion's LOD and the LOD in Fallout 3.

To create landscape LOD meshes, simply go to World -> World LOD..., select your world space, and click on the Generate Terrain Meshes button. This will give you a pop up warning you that the process could take "up to 10 hours". (On my own system, generating the Wasteland LOD meshes took about six hours and ten minutes.) Click Ok and the process will begin. The Geck may appear to stop responding, but this is normal and in all likelihood the LOD generation process is proceding smoothly in the background.

The Geck is 'Not Responding': There are many occasions in which the Geck will appear to 'hang' with a 'Not Responding' message in the title bar. Most of the time, this simply indicates that the editor is involved in a complex, processor-intensive task and is not able to respond to Windows messages. Eventually, it will finish whatever it's doing and you will regain control of the application. This happens to me every time I start the Geck and when generating LOD landscape mesh data. Sometimes, it may indicate a crash, in which case you will have to close the program manually using Windows Task Manager (Ctrl+Alt+Del, Task Manager, select Applications tab, select Garden of Eden Creation Kit, select End Task). Unfortunately, there is no easy way to know for sure which of these things is happening. Typically, however, when the Geck crashes, you will receive a clear indication from Windows that the application has stopped working, so if it is simply 'Not Responding' I recommend waiting it out. When generating LOD landscape meshes, you can actually verify that the program is still operating by keeping an eye on your Data/Meshes/Landscape/LOD/editor id of your world space directory. If it is working, you will see new meshes appearing here every few minutes. If nothing appears here after a long wait, you might want to try closing the editor and restarting the process.

Error: First segment of segmented tri shape has a start index other than zero.

Eventually (after a few minutes, in my own case) the Geck will issue a warning that the "First segment of segmented tri shape has a start index other than zero". I have no idea what this error really means, though it may have something to do with the way that the Geck generates LOD land meshes: because it generates chunks beginning with 4x4 cell sections, it may be caused by having world spaces that are not evenly divisible by 4 in both directions. (If you look at your LOD underwater in-game at the edges of your world space you will likely see various sorts of LOD land mesh errors. These are not harmful and seem to be caused by the Geck's attempt to generate an LOD mesh using cell data from a cell which "doesn't exist" because it contains no data.) In any case, it does not appear to affect the LOD in-game and can be safely ignored. Just click 'Yes to All' and let the process continue.

During the time that the Geck is generating the meshes, it will in all likelihood refuse to respond to any other requests from Windows (for example, clicking on a menu). It will also likely indicate that the Geck is 'Not Responding' in the title bar. As noted previously, this is nothing to worry about. You just have to give it time to complete the process. That is why it is generally best to start the LOD mesh generation process only if you don't need to use the Geck for an extended period of time. (Many people start the process before going to sleep at night or before leaving for work.) Just remember to wait for the first warning and click 'Yes to All' before abandoning it to its own devices. You may also want to temporarily disable sleep mode on your system to keep it from pausing the process when your computer becomes inactive. Unless you have a very old rig, you should be able to continue using other applications while the Geck is generating the terrain.

Handling Editor Warnings: If you click 'Yes' when you receive a warning from the editor, you'll have to respond to each additional warning until you click 'Yes to All' or 'No'. (If you click 'No' the Geck will shut down so don't click it unless you really mean it.) This is fine if you are working on other tasks, or if you want to babysit the LOD generation process, but it can slow you down considerably when performing a labor-intensive task like this (the Geck issues literally hundreds of warnings in some contexts). If you are really concerned about them, you can always get the generated warnings from the EditorWarnings.txt in the Fallout 3 directory for follow up. It is a good idea to keep an eye on this file in any case if you're working on a large or complicated mod.

When the Geck is done generating the meshes, you should see a new folder located here: Data/Meshes/Landscape/LOD/editor id of your world space. This folder will be filled with files called 'name of your world space'.Level4.x coordinate.y coordinate.nif. Depending on the size of your world space, there will also be Level8, Level16, and Level32 nifs as well. You can use the coordinates in the file name to determine which part of the world space each file represents. Chunks are created starting from the bottom left corner of a 4x4, 8x8, 16x16, or 32x32 cell group. For example, if your file is 'name of your world space'.Level4.X0.Y0.nif it represents the cells from X0,Y0 (bottom left) to X3,Y3 (top right). (This detail can be useful to know when you need to update a specific chunk of LOD but you don't want users to have to redownload all of the files.)

Once you're done generating your LOD land meshes, you can move on to generating the LOD textures.

Generating LOD Textures

To generate the LOD textures and get them working in-game, you must do a couple of things. The first thing you have to do is unpack all of the necessary landscape textures to your Data/Textures/Landscape/ folder. If you haven't unpacked your textures, your LOD will look purple in-game. The second thing is simply to click the Generate Terrain Textures button in the World LOD dialog. Generating textures is much, much faster than generating LOD meshes so this shouldn't take too long. (A small worldspace will likely only take a few seconds.) The trick to generating LOD terrain textures is knowing what the Geck does with them when it's done!

When you generate LOD textures, all of the textures will be placed in a new folder within your Bethesda Softworks directory (in other words, NOT in your Fallout 3 directory, but one up from it) called Source. The file path is actually: Bethesda Softworks/Source/Textures TGA/Landscape/LOD/editor id of your world space. This folder contains three sub-folders called Diffuse, DiffuseGenerated, and Normals (and eventually Blocks and Trees once you've generated LOD objects and LOD trees). The color textures are located in the DiffuseGenerated folder and have to be copied to the Diffuse folder to be visible in-game (the Diffuse folder is empty by default). The Normals folder contains the normal maps for your landscape mesh. If you don't know what a normal map is, I recommend you look it up on Wikipedia, but essentially it's an image file that tells the engine how to bounce light off your mesh to create realistic shadows.

Once you have copied your DiffuseGenerated files to your Diffuse folder (or deleted your Diffuse folder and renamed your DiffuseGenerated to Diffuse) copy the whole folder (the folder named after your world space and all the sub-folders I just described) over to your Fallout 3/Data/Textures/Landscape/LOD/ directory. If you forget this step, you will end up with purple textures in-game, so don't forget!

Tip: When you generate the LOD objects and trees (the next two steps) the Geck will create additional folders inside Bethesda Softworks/Source/Textures TGA/Landscape/LOD/editor id of your world space so I usually don't copy over these files until I'm done generating all of my LOD data.

Generating LOD Objects

Now that you have your LOD land mesh and landscape textures generated, you need to generate the VWD object data. The Geck does not generate miniature versions of these objects for you: you'll need to unpack the vanilla LOD meshes and textures in order to generate this data. If you are using custom meshes, you will need to create simplified LOD versions of these objects in your modeling program and place them in the appropriate folders. When you run the Generate Objects function, it essentially takes these models and creates a new mesh object out of them using the location and rotation data of the original objects to position the LOD versions: when your character moves out of range, the original, high-poly objects are unloaded from memory and the VWD LOD objects are displayed instead.

Note: If you are making LOD versions of custom meshes, these versions do not require any collision. The player will never get close to these objects, so the collision is unnecessary. In fact, having collision will just force the processor to perform unnecessary calculations and eat up your framerate. Also, don't forget to tick the VWD flag on the object dialog in the Geck for your custom object.

Error: One or more LOD blocks failed to build.

If you try to run Generate Objects and one of your objects is missing a LOD model or texture, the Geck will inform you of the error and the procedure will fail. The easiest way to ensure that all of your VWD objects generate correctly is to unpack all of the meshes and textures to your data folder. If you prefer to keep a tidy computer, you can check each mesh for the required .nif and .dds files and unpack just the ones you need. You'll also need to convert the .dds textures files to .tga files which you can do in an image-editing program like the Gimp. (Just open the .dds file in the Gimp and save it as a .tga file. Default settings are fine. You will need the Gimp .dds plugin to do this.) You have to move these converted files to the Bethesda Softworks/Source/Textures TGA/ folder for the Geck to find them. The files have to be placed in folders corresponding to the location of the original files, so if the LOD texture you converted is from the Data/Textures/Architecture/Wasteland folder, you have to place it in the Bethesda Softworks/Source/Textures TGA/Architecture/Wasteland/ folder. (If the filepath doesn't exist, you'll have to create it manually.) If you're feeling really ambitious, you can go through all of your LOD .dds files and convert them to .tga files before starting the LOD Object generation process. Just search the texture folder for files with the "*lod" wildcard. Most of the rocks share a couple of common LOD files and there may be other overlaps as well, so you won't need to unpack textures for every single object. Most of these textures can be found in the Data/Textures/Landscape or Data/Textures/Architecture folders.

Once the LOD object data has been created, you need to copy the generated textures from Bethesda Softworks/Source/Textures TGA/Landscape/LOD/editor id of your world space to the corresponding Fallout 3/Data/Textures/Landscape/LOD/ directory. If you forget this step, your LOD objects will have purple textures in-game.

Note: It is extremely important that you have all of your files in the correct folders to get these build processes to work properly. Forgetting to put a required file where it is needed is the most common error made when generating LOD data. If you are having problems with your LOD double-check the requirements and make sure everything is where it should be. If you're not sure if something is required or where it should go, check the vanilla files for guidance.

Generating LOD Trees

You can generate LOD tree data by clicking the Generate Trees button on the World LOD dialog. This will create a tree block containing LOD information about all of the speedtree (.spt) trees and all static object trees (the dead ones) with the 'Has Tree LOD' tickbox checked in the static object dialog. Like VWD objects, you will need to unpack the tree lod meshes and textures so that the Geck can find them. You'll also need to copy the treedeadlod.dds file from the Fallout 3/Data/Textures/Landscape/Trees/ folder and convert it to a .tga file in the Gimp (or other image editing program) and place it in the Bethesda Softworks/Source/Textures TGA/Landscape/Trees/ folder to execute the build process. Unlike the LOD Object build process, the LOD Tree build process will not inform you if it failed to build. You will simply have to check your Data/Meshes/Landscape/LOD/editor id of your world space/Trees/ folder for tree blocks. If you don't see any, you'll know the blocks failed to build.

Floating Trees: There is a bug with LOD tree regeneration for vanilla worldspaces: if you regenerate the LOD tree data, the vanilla LOD doesn't update properly for trees that have been moved or deleted and you end up with low-poly 'ghost' trees (low-res tree billboards without collision) in-game. The regeneration process will correctly adjust the x and y coordinates of moved trees, but will not adjust the z coordinate correctly (there is a small height discrepancy) and does not copy rotation at all. It is not known at this time the exact cause of this error, though it only appears to affect trees in a master file that have been moved or rotated. To get around this issue, you can drag vanilla trees below the landscape mesh so that they are no longer visible and regenerate the tree LOD. Trees that have not been edited will regenerate properly. It is recommended that you do not delete vanilla references (eg. trees). If another mod tries to reference a deleted object, the game will crash.

Regenerating LOD

It goes without saying that you will need to generate all of your LOD after you have completed shaping and texturing your terrain mesh and adding your trees and VWD objects. It will be one of the very last things that you do before releasing your mod. But that doesn't mean that you can't generate all of this data sooner for testing purposes. You may generate this data as often as you like, as long as you remember to delete all of the previously generated data before starting a new round of generations. Of course, the size of your world space may dictate how often you can afford to generate this data: if your world space is very large and generating the LOD meshes takes several days to execute you're not going to want to do it very often.

My recommendation is to get your heightmap/landscape shaping finalized and then generate the LOD meshes for it. Generating the other LOD data is relatively quick and painless, so you can retexture and add and remove objects and trees as much as you want as long as you don't change the shape of the landscape mesh too much (ie. not enough to be noticeable from a distance). The only thing you need to remember is that the Geck will not regenerate data that already exists so before regenerating your LOD you need to delete or remove the files that you've already generated.

The following files are generated by the LOD build process (not all of these files will exist if you haven't gone through all four stages of the build and/or one or more of the files failed to build for some reason):

Packaging LOD with Your Mod

When you distribute your mod for others, you will need to remember to include the following files:

You do not need to include the files in the Source directory that were generated by the Geck. You should have transferred the necessary files over to your Textures folder earlier in the build process.

Regenerating Wasteland LOD for Your Mod

If you have made changes to the Wasteland landscape (or another vanilla world space) you may regenerate LOD for that world space so that your changes are reflected in the distant LOD. Regenerating the entire Wasteland world space LOD can take a very long time. The landscape LOD mesh generation process took a little over six hours on my system. Others have reported similar durations, typically around the 8 hour range. Some have reported being unable to generate the Wasteland LOD at all, however, so if you have an older rig you may experience problems in this area. In that case, you may have to find someone else to generate your LOD data for you.

A better solution than regenerating the entire landscape is to find out which chunks your mod alters and then to regenerate only these chunks. The details for this procedure can be found here: LOD Grid to Cell Grid Conversion Chart.

Troubleshooting

Below are some of the most common errors associated with LOD in Fallout 3 and solutions to them (where possible).

Phantom Landscape

Phantom landscape

When the LOD landscape mesh projects through the actual landscape and obscures it you have phantom landscape. Phantom landscape can be identified by the low-resolution texture and by its lack of collision (ie. you can walk through it). To fix phantom landscape, you have to regenerate the LOD landscape mesh.

Floating Trees

Floating trees

When you move trees in the Wasteland (or any other worldspace with LOD) you end up with floating trees or ghost trees: low-resolution tree billboards with no collision at the location originally occupied by the tree. Unfortunately, there isn't an easy, elegant solution to this problem. If you regenerate the tree LOD, the LOD trees will correctly update their x and y coordinates, but the z coordinate is usually 'off' and any rotations applied to the mesh are ignored. The best solution is to move unwanted trees below the landscape mesh so that they are no longer visible (pull them down at least a couple hundred units) and then regenerate the tree LOD. (If anyone knows a better solution, please contact me.)

Deleting References: Do not delete vanilla references, including trees: deleting references in a master file will cause your game to crash if the game or another mod tries to access the deleted reference. Don't assume that nobody will; modders are a creative bunch and will find a way to use everything!

See also: Creating Custom Worldspaces

See also: G.E.C.K. Editor Warnings and Solutions

See also: LOD at Wikipedia

Comments

Feel free to comment, but please be civil and constructive. Inappropriate, inflammatory, and spam-related comments will be deleted.

***

Last updated October 3, 2011

© 2009-2011 Dave Finch