LOD Generator

Introduction

A single integrated tool inside the Sandbox Editor that facilitates the generation of both geometry LODs and material LOD's for static geometry. Integration with the editors source control means all files are automatically added to source control change list.

Integration with the editors python scripting means that LOD's can be generated autonomously as part of a batch system or overnight process. All settings are saved out to an XML file so that future work on the same asset is quick and easy to replicate.

User Interface

Firstly open the Sandbox Editor and open the 'LOD Generator' from View -> Open View Plane.

The default view for the tool is docked on the right hand side of the editor.

The initial state of the tool is showing you the geometry generating section, however if your just interested in generating material you can skip the following sections and go directly to the Material Generator overview.

If you opened the LOD Generator without an object in the view port selected the above image is what you will see. If you pre-select an object the LOD Generator will automatically load that asset and you will see something like the image below.

File Panel Overview

The file panel is where you can load an asset in to the LOD tool either by browsing for the specific file, or selecting the asset in the view port and clicking the 'Use Selected Asset' button.

From left to right and top to bottom a brief description of the controls:

OptionDescription
Source CGF PathThis is the path to the CGF the LOD tool will use for generating.
Open File ButtonThe user can click this to browse to and find a specific CGF to load.
Use Selected ButtonThe user can click this to load the model they currently have selected in the viewport.
Material PathAfter loading a CGF the material path displays the file path of the material that will be used during the generation process.
Material Editor ButtonClicking this will open the material editor at the specified material allowing a user to check and tweak the material if required.

Geometry Generator Overview

The work flow for generating geometry should be to load the CGF to generate LOD's for, setup the geometry generation options, generate the LOD chain, specify required LODs for export and finally to generate the files and new sub-material.

Geometry Options

These are automatically set to keep the bake time reasonable (30s -> 3m) but could require tweaking. At the very least make sure "Object has base" is correctly selected.

Geometry Bake OptionDescription
Object has baseIf this isn't enabled then no views from below the origin will be considered. This effectively halves the views specified in "View elevations".
Pixels per meterControls the resolution of the views. The higher the value the better the results but will also slow down the process.
Views aroundControls the number of views around the Z axis at each elevation. See diagram below.
View elevationsControl the number of views in the Z axis. See diagram below.
Silhouette weightingControls how important the silhouette is considered (in multiples of the object radius).
i.e. A setting of 50 means a one pixel silhouette change is equal to 50 pixels moving from the front of the object to the back.
Vertex weld distanceBefore starting the LOD'ing process vertices within this distance will be welded together. Be warned this can create bad geometry which interferes with the topology check.
Check topology is correctAvoids moves that will create "bowties" (a vertex connects two faces that don't share an edge) or "flaps" (an edge has more than 2 faces connected to it).
This helps the LOD generator from creating bad geometry (which can lead to messy results).
However some models have this type of geometry to begin with which could mean the LOD baker does not move these vertices at all. In this case you should turn off the topology check.
Toggle WireframeThis option will render the LOD preview in a solid white color.
Toggle obj exportWhen enabled, this will save an obj file per LOD to disk in the folder _obj.
PreviewSourceLodThis option will give you preview panel displaying the source LOD.

Geometry Task Panel

Once the settings are correct then click "Generate LOD Chain". This will create a number of models ranging from full polygon down to zero polygons (or the lowest number possible without violating the topology check).

This can take some time. The time scales with number of views and resolutions.

Please note that the ETA is just an estimate. If the generation is taking too long you can use the cancel button to stop and tweak the settings for better performance.

Geometry Generator Panel

Here you can preview a LOD at a given percentage specified by the key on the ramp at the bottom of the preview window. You can add as many LOD keys as the engine supports. The model shown is a wire frame version of the LOD.

The error graph shows how the error (as detected during the LOD'ing process) changes as the polygon count is reduced. This could be useful to hone in on sweet spots in the LOD. The graph also shows statistics about the currently selected LOD like its poly and vertex count.

Once you've selected the point in the LOD chain that looks acceptable you can add another LOD by double clicking on the ramp. Any existing LOD's that the object has will automatically generate a key at the position matching the percentage of triangles to LOD has in relation to the source model.

Once your happy with the LOD's you want to generate click 'Generate Geometry Files'. This will save each key to the specified LODs geometry file also generating UVs for the LOD model and creating a new custom sub-material in the Material file.

All these files will be added to a change list in source control should you have it enabled.

Material Generator Overview

Creating Material LOD's for an assets geometry LOD's can be done in the same LOD tools, once you've selected the model in the file panel, if you generated geometry LOD's this will already be the case, you can set-up the options for baking each LODs material.

Material baking is done using two geometry models, the source LOD usually the high poly model and the destination LOD case, a low poly LOD model. Rays are cast though the models and the hits against the high poly model are used for sampling the pixel color value for the texture.

Material Generator Options

Material Bake OptionDescription
Ray Test LengthThe distance to ray cast for hits on to the surface of the source LOD.
Ray Start DistanceThe distance from the model to start the ray cast.
Bake the Alpha ChannelWill create a diffuse texture with an alpha channel for objects that contain transparent geometry.
Smooth CageWill smooth the normals of the LOD cage to help reduce artifacts.
Dilation PassWill reduces filtering errors by filling in none baked areas.
Background Color
Used to fill any areas of the texture that didn't get filled by the ray casting.
Export PathThis is automatically filled out when the object is selected.
File name PatternThis is automatically generated and should be left as default.

The main settings you will need to tweak here are Ray Test Length and Ray Start Distance, try baking with the default options before tweaking.

Individual LOD Settings

Each LOD has some individual settings that can be tweaked to customize the baking, mainly the texture resolution for the LOD.

At present you can only tweak the first LOD's texture sizes and the subsequent LOD textures are set at a factor of two smaller than the first LOD's setting. Also you can disable baking specific LOD's if you wish.

A preview of each generated texture will appear in the Diffuse, Normal and Specular panels once you have generated the textures. Also a preview of the Source LOD that will be used to bake the LOD's textures down is displayed in the preview panel on the right.

Generate Textures

Once you're happy with the settings hit the Generate Textures button, the baking will begin and once finished the previews will be updated.

Automatically, the textures will be assigned to the correct Sub-Material and the Material will be saved.

All generated textures will be added to the change list in source control with the material ready for submission.

Here is the view of the folder after generation: