# Automatic LOD Selection using CNNs In Computer Graphics, the building block for representing a geometry is by using triangle primitives. Triangles are efficient in terms of memory, but for constructing a realistic-looking object, we must put lots of triangles together. In realtime rendering, there has an upper limit for the amount of time spent to render each frame. More triangles mean more computation time, and this leads to a jerky scene. Speeding up the rendering process is an active area of research in the field of computer graphics and realtime rendering.

One easy way to make things faster is by using different models with different levels of details. When an object is far from a camera, it will occupy a small subset of pixels in the final image. Spending too much processing power for a task that only affects a small portion of the final image is pointless. This sounds like an optimization problem; Which model should our game use when an object is at distance $$x$$ of the camera?

## CNNs to the Rescue

The whole point of switching the geometry of an object is to not CPU and GPU computation on objects that are tiny and hard to recognize. So, why instead of traditional metrics, we don’t use an Object Recognition network to decide when we should switch our geometry. Let’s formulate our problem: We have object O at the distance $$x$$ of the camera, and it will occupy $$y$$ pixels of the final frame. We have $$n$$ LODs for this object with a different number of triangles (First LOD has the highest details, and the $$n$$-th LOD is the simplest). We also have an Object Detection network called ObjNN, which has trained on our objects (2D images of them).

We consider the transition between LOD level $$l_1$$ to LOD level $$l_2$$ as a good only if ObjNN outputs a higher accuracy for $$l_2$$ for the object O. Not much difference in detection scores when the object is far away.

This method doesn’t work for the objects that are close to the camera. All LOD levels will yield a very high score for the True class. A solution to this to train a CNN based on Human preferences. That is, train a network to learn and replicate a player decision in different scenarios, rather than solely rely on the detection scores.

## Don’t Get Too Excited

The above formulation is rudimentary, but at least it gives you an idea of how to incorporate a neural network for similar tasks in computer games and graphics.

One important note to consider is here is the weird and unpredicted behavior of CNNs (and neural networks in general). In the image below, you can see object detection algorithms can be fooled with modification in angle and position of objects, as well as the wrong classification of objects that have not been seen before by our network. You can read more about this Here and Here.