HowTo/Understand Level of Detail in Trainz

From TrainzOnline
< HowTo(Difference between revisions)
Jump to: navigation, search
Line 32: Line 32:
 
Here we see a single area of 500,000 logs that are situated 200 meters away from the camera. The logs themselves take up a land area of roughly 50m x 150m = 7,500m². We have then copied the 10m x 10m grid from close to the camera, and pasted it back by the logs. You can see that the logs would actually fit in a single 5m x 5m grid or 25m².  
 
Here we see a single area of 500,000 logs that are situated 200 meters away from the camera. The logs themselves take up a land area of roughly 50m x 150m = 7,500m². We have then copied the 10m x 10m grid from close to the camera, and pasted it back by the logs. You can see that the logs would actually fit in a single 5m x 5m grid or 25m².  
  
We have compressed 7,500m² of objects into just 25m², but what is important for the computer is not land area, but rather pixels on screen. Let's do the maths:
+
We have compressed 7,500m² of objects into just 25m², but what is important for the computer is not land area, but rather pixels on screen. Let's take a look at the next image and do the maths:
  
Across the screen at the bottom, there are 1280 pixels and roughly 5 x 5m grids or 25m across (a pixel is the smallest dot of colour on your screen). Therefore a 1m long object that is 1 pixel high would be 50 pixels in width. A 1m x 1m image would take about 2,500 pixels to render (50 x 50 pixels).
 
 
Next, at 200m distance, our logs which spread almost 50 meters across, are actually taking up less than a fifth of the screen width. So now our 1m long object is just 5 pixels wide! (i.e. 50m represents 1/5th of our screen width = 1280 pixels/5 = 250 pixels).
 
 
So just 200m distance from the camera reduces the resolution from 50 pixels per meter to just 5 pixels.
 
 
To understand this a little more, let's take a look at some more examples:
 
  
 
[[file:Pixels.jpg|800px]]
 
[[file:Pixels.jpg|800px]]
Line 48: Line 41:
 
What all this means when creating models is that once an object is more than 200 meters away, it is already about a quarter of the size. We've also grabbed the buildings from 500m+ and pasted them in the foreground to show how much detail is lost at that distance.
 
What all this means when creating models is that once an object is more than 200 meters away, it is already about a quarter of the size. We've also grabbed the buildings from 500m+ and pasted them in the foreground to show how much detail is lost at that distance.
  
The end result is that we have many more pixels to provide detailed textures on an object up close, and all that resolution disappears into a fog of pixel soup in the distance (as shown in the next super close-up image). In fact, our horizontal grid line has run out of pixels altogether!
+
Across the screen at the bottom, there are 1280 pixels and roughly 5 x 5m grids or 25m across. Up close, we get 20 pixels per meter, or 400 pixels per square meter of ground/object coverage. Less than 100m away from camera, our resolution has already dropped to 10 pixels per meter, which works out at just 100 pixels per square meter - a quarter of the resolution. By the time we are over 500 meters away, we are looking at 2 or 3 pixels per square meter. Remember, you can't have half a pixel, since a pixel is the smallest unit we have to work with.
 +
 
 +
The end result is that the further away from camera, the more the resolution disappears into a fog of pixel soup (as shown in the next super close-up image). In fact, our horizontal grid line has run out of pixels altogether!
  
 
[[file:super close up.jpg|800px]]
 
[[file:super close up.jpg|800px]]
 +
 +
The next thing to look at is polygon count and how this impacts both the look of an object and the performance or frame rate of the game. Trainz provides the user with extreme flexibility in terms of camera views and world size. Horizontally you can zoom in to see items from less than 1m or look across the world up to 5km in the distance. Looking straight down, you can zoom in to see roughly a 10m x 10m grid or zoom out to see a 40km x 50km area.

Revision as of 17:13, 24 March 2014

This page sets out to explain in layman's terms why Level of Detail (LOD) is the most important tool a content creator has to make their assets both look good and perform well in-game.

We'll start by taking a look at 10 million logs using 4 x LODS in the following image. The logs are built in stacks of 20 logs (i.e. one object = 20 logs) and have been placed in groups of 250 objects per area (so that is 20 x groups of 500,000 logs, or 10M logs in total).


Log pile 10M - standard LOD - close up.jpg

We've turned our performance monitoring tools on to record what is happening on screen, and we've added some labels to explain what you are seeing. Let's go through things one by one:

The stats show that we are looking at 4250 of the piles of logs (8.5M logs in total) and there are 4.5M vertices on screen (roughly speaking, 3 vertices per triangle).

The arrows point to the point where the LOD changes. The first change is there, it's just almost impossible to see that the LOD1 arrow is pointing to a 550 poly object and not an 880 poly object.

The LOD 2 change has been highlighted by the two circles. You can just make out the different shading on the "round" logs versus the square logs used in LOD2.

At the back, it is so far away that in this case, again there is no visible difference when the lod changes.


Log pile 10M - standard LOD - close up 2.jpg

This time we have placed at the front (near camera) the four different LOD objects that range from 880 polys (triangles in Trainz) in LOD0 down to just 92 polys in LOD4. To show these items this close to camera, we exported them as individual items. Even at just over 10m camera distance, it is difficult to differentiate between LOD0 and LOD1. You may be able to notice that the logs have reduced from 12 sided objects to 8 sided.

The bigger step is to LOD2 where our logs become square objects, and then the final step is to replace all that geometry with a few textures planes.

In the background are all our logs. The lines indicate the approximate point where the LOD changes to the next lowest level of detail. The first change is imperceptible. Lod1 > Lod2 is only noticeable due to a very slight colour change, and from this low camera view, LOD3 is hardly visible at all (which further illustrates the importance not to waste polygons out in the far reaches away from the camera.

Next we'll look at why this technique works, and it is all to do with the way the camera views the scene.


Log pile 200 - 200m.jpg

Here we see a single area of 500,000 logs that are situated 200 meters away from the camera. The logs themselves take up a land area of roughly 50m x 150m = 7,500m². We have then copied the 10m x 10m grid from close to the camera, and pasted it back by the logs. You can see that the logs would actually fit in a single 5m x 5m grid or 25m².

We have compressed 7,500m² of objects into just 25m², but what is important for the computer is not land area, but rather pixels on screen. Let's take a look at the next image and do the maths:


Pixels.jpg

Our 3D world is an amazing place. Two parallel lines look closer and closer together the further they get from the viewpoint. Similarly, taking one of our grid lines from the foreground and pasting it onto the world in the distance shows just how much the perspective has changed. Our brain is so good at recognizing this effect that it fools us into thinking the grid and arrow at the back is bigger than the one that is close to us.

What all this means when creating models is that once an object is more than 200 meters away, it is already about a quarter of the size. We've also grabbed the buildings from 500m+ and pasted them in the foreground to show how much detail is lost at that distance.

Across the screen at the bottom, there are 1280 pixels and roughly 5 x 5m grids or 25m across. Up close, we get 20 pixels per meter, or 400 pixels per square meter of ground/object coverage. Less than 100m away from camera, our resolution has already dropped to 10 pixels per meter, which works out at just 100 pixels per square meter - a quarter of the resolution. By the time we are over 500 meters away, we are looking at 2 or 3 pixels per square meter. Remember, you can't have half a pixel, since a pixel is the smallest unit we have to work with.

The end result is that the further away from camera, the more the resolution disappears into a fog of pixel soup (as shown in the next super close-up image). In fact, our horizontal grid line has run out of pixels altogether!

Super close up.jpg

The next thing to look at is polygon count and how this impacts both the look of an object and the performance or frame rate of the game. Trainz provides the user with extreme flexibility in terms of camera views and world size. Horizontally you can zoom in to see items from less than 1m or look across the world up to 5km in the distance. Looking straight down, you can zoom in to see roughly a 10m x 10m grid or zoom out to see a 40km x 50km area.

Personal tools