.

Trainz Developer Blog

Using LOD effectively

Rating: 2 votes, 5.00 average.
When to use LOD?

Mesh LOD is most useful in two distinct scenarios:
  • When a single object is very highly detailed, such that it is reasonably "expensive" in its own right.
  • When an object may be used repeatedly throughout the scene, such that it is "expensive" in total even if not per object instance.


As an example of the first, we can consider our 1000 polygon skyscraper. Even if there is only one instance of the skyscraper in the scene, reducing it to 50 polygons in the distance would give us a notable saving- probably not something that you'll see reflected immediately in the frame rate (950 polygons really isn't much) but when you consider that there are hundreds of other similar objects in the scene, the overall saving might be hundreds of thousands of polygons.

For the second, consider a low-detailed tree. The tree might only have 50 polygons. The GPU doesn't even get out of bed for less than a few hundred polygons. How can reducing it further benefit us? But consider there are 50,000 trees in the scene. Based on our figures above, this is approximately a density of one tree every 16m. The combined cost of this forest is 2.5 million polygons, and with mesh stitching that might actually be distributed as 80 composite objects of 31,250 polygons each. Now this is very worth reducing. If we can get that down to 5 polygons beyond 1000m, that brings us down to a total of 340,000 polygons - that's a massive saving. If the forest was solely responsible for your 10fps frame rate, you might be getting above 60fps after the LOD was introduced.

How many LOD levels?

There are a few questions that need to be asked when considering how many LOD levels are appropriate for an object:
  • How low can we go in the extreme distance? Ideally, this should be in the 10-50 polygon range, but really heavily used object can consider going lower and really sparsely used objects may not bother going quite so low.
  • How many polygons are we putting in our original model?
  • How much of the original model's detail is minutiae that can be dropped out almost immediately, and how much is structural and will need to persist quite a way into the distance?
  • Since we know that LOD will keep our average polygon count down, can we consider improving the detail of the original model? (ie. trading off for better visual quality and a minor performance improvement, rather than equal visual quality and a more substantial performance improvement.)


It's fair to say that each LOD level should aim to drop approximately 50% of the detail from the previous level. With a detailed object which has several LODs, the first change may happen quite close to the camera. In this case, we can drop off some of the "noise" elements in the geometry back to a simpler version, and perhaps reduce the number of detail in any curved surfaces. Small details that are nearly flush with the surface can perhaps be removed and the newly-revealed texture used to hide the fact that some geometry is now missing. You might want to avoid going for the full 50% drop and aim at 40% or even 30%. Or perhaps you really can flush out a lot of unnecessary stuff and get an 80% drop. Don't go in with preconceived numbers, but rather consider use the 50% per level as a ballpark that you need to maintain across the whole LOD sequence.

You definitely don't want to be keeping unnecessary detail around. If you can drop 80% and get an acceptable result, then do it! Likewise, you don't want to drop so much detail that the transition becomes very obvious. LOD changes will always be visible if you're staring straight at the object, but your job as a creator is to ensure that a LOD change which occurs somewhere random in the scene does not tempt the user to flick their eyes over to see what moved. If you have a constant "popping" sensation while moving through the scene, then the LOD is less than perfect.

You should never drop less than about 30%. If you're finding that a 50% drop is too noticeable, then you should first consider whether you've done a good job of your LOD modelling. Have you perhaps removed some colored/shaded detail and not replaced it with an equivalent color/shade in the revealed texture? Have you forgotten to use a normal map generated from your high LOD geometry? Have you broken your object's silhouette when you could have taken more of the small details out instead? Have you considered whether you can replace complex modelled detail with an alpha-masked texture? Have you removed any interior or occluded polygon detail that is invisible from this distance? If you are convinced that you have done the best job possible, then you should consider using a lower reduction- perhaps 40% or at most 30%. A 30% reduction is really quite minimal (remembering that the 'theoretical' goalpost is more like 75%) and you should not be having problems at this range. If you're really stuck, perhaps reconsider the overall LOD construction and determine whether you should drop slightly less detail in a higher LOD and more detail in this LOD.

Your overall goal is two-fold, and comes back to the two scenarios described at the beginning of this section. For a very-high-polygon object, your goal is to get down to something smaller as quickly as possible. For a heavily-used object, your goal is to ensure that the lowest LOD is as small as possible. You can and should apply both goals to the same object where relevant. Why stop reducing a skyscraper at 500 polygons when you can go down to 50 polygons without any visual problems? Sure, dropping to 500 was an easy win, but that doesn't mean you can't do better.

For the heavily-used objects, it is better to reduce more slowly if necessary as long as you can get the lowest LOD as simple as possible. Your low LOD accounts for more than 90% of your object instances in the scene, and more than 50% of the polygons, so the single biggest gain you can achieve is to reduce your low LOD further. If you have to introduce one or two more LOD steps to achieve this smoothly, and you have to push a little more detail into the closer LODs, that's still a net win.


Further information is available on TrainzDev Wiki pages: Level of Detail, LOD Example and Modelling Guidelines.
Categories
Uncategorized

Comments

  1. Lendorf's Avatar
    Looking at a TS12 V3.7 spline like a tunnel or bridge as example, where the LOD transitions in the distance of the lower LODs are referenced as meters away, where this LOD change is happening, why can not the same/similar "distance in meters" referencing be made for some scenery LODs implementation in their configuration? The way this is done presently is an arbitrary non defined distance, depending on several things beyond the control of a creator of such scenery items.

    This would prevent the sometimes very visible "popping" between say, from LOD0 to LOD1 on some scenery items in TS12, when this happens to be VERY close to the observer. As a creator of such scenery items then would have a little control where such change of LODs should happen. Of course, good creators will not specify ridiculous distance away changes, only a little further away where this transition is not so noticeable. As it is not always possible to reduce a Hi detail LOD to the next LOD without making, as said, this visual noticeable "popping" effect.

    Remember, I wrote "not always", most of the time, yes, a creator can/should/must create a somewhat smooth transition from LOD0 to LOD1 and so on. With trainzcars a creator can control and specify the LOD change by the size of the object compared to the view available (size of the trainzcar seen on screen or something like it). Why not similar or as in meters for some specific scenery items, obviously trees and the like excluded?

    Lennard