LOD swapping
LOD (Level of Detail) swapping is one of the most useful optimization trick with any editor. GameCore's LOD swapping process is particularly painless and can be done directly in the editor using the built in Properties Editor, or can be done by manually editing the object's properties file, as shown below.
In this example, we will be manually editing the objects .opr (Object Properties) files but only adding a few lines. Lets build a scene real quick to demonstrate the process.
Check here for more information about GameCore Properties files & how they are used
I have added a terrain object and enabled the sky system.
I have added two template objects to the scene, an editable box and an editable sphere. I have made the box blue and the sphere red just to aid in the visual demonstration. Here is what my scene currently looks like:

We are going to pretend the sphere is the high LOD object and the box is the low LOD. Open the sphere objects .opr file by click 'Edit Properties' and in the .opr window click 'Edit as Text'. This will open the object .opr file in a text editor.

90% of the editable sphere's .opr file is texture information and can be ignored for this process. In fact the only line that important really is the load object call:
LoadObject Editable Sphere.box
This states that as the world is built and it gets to this .opr file it will add the object Editable Sphere.box
Now lets set up the editable box for LOD swap.
What you need to do (and this is because they are editable box objects) is export the box as a new piece of geometry. Go to Tools -> Export geometry and call the exported object box1. GameCore will build an .opr file for box1 this way.
Note: exporting your geometry is not typically required if you have custom 3d geometry that you are using as your LOD objects
Now go back into the sphere's .opr file and right under the LoadObject call for the sphere add the line:
LoadObject box1.opr
Now your sphere should be a red box:

Now we need to add a few more lines of script to get the oobject to switch between the two load object calls. LOD swapping is based on distance. The closer to the camera the higher the LOD of the object. For example a shrub at high LOD could have 30 planes, the low LOD could be just two planes crossing with the image of the normal shrub on them as the texture. So lets look at the scrip that controls the Depth of an object. The two properties you will need are:
ObjectMaxDepth - which sets the maximum distance from the camera the object will appear
ObjectMixDepth - which sets the minimum distance from the camera the object will appear
Lets continue editing our sphere object's .opr adding these lines and some numerical distances (in meters):

I have set the max depth of the sphere at 15 (meters). This means from 0-15 meters the sphere object will be loaded.
I have set the box1 object min depth to match the max depth of the sphere (high LOD object) and a max depth of 40. This means at 15 meters it will load the box (low LOD) and after 40 meters (max depth) it will not load anything. Here is a rough image that shows the three states:

To eliminate some of the 'popping' associated with LOD swaps we need to add a Fade between the two states. This works just like setting up the depths for the LODs. At a point when the LODs swap add the line(s):
ObjectMaxDepthFade #
ObjectMinDepthFade #
These lines will fade between the LODs for the given # (number in meters). A depth fade of 10 will fade between states for 10 meters. This will eliminate your popping but be careful about optimization. Using this will have (over the course of the fade distance) both objects being drawn.
That's the basics of LOD swapping. Happy optimizing.
A few additional notes:
- You can specify any number of LOD swaps for an object using this same technique
- When you change the 'detail level' in your game (either in the editor under the 'options' menu or in game at runtime), GameCore will automatically adjust the values used in your object LOD's - so a user running a game at 'Low' detail will see the swapping closer and a user running the same game at 'Maximum' detail will have the LOD swapping occur at a further detail. It is a good idea to design your game for either 'Medium' or 'High' detail and the engine will dynamically scale your game appropriately.
Printer-friendly version- Login to post comments
- PDF version
