Welcome back to the second part of our discussion on Level of Detail meshes! This blog post will be slightly shorter as it primarily builds upon the concepts introduced in the first post. In the first draft, we focused on calculating the LOD based on the diameter of an object. However, since the player in a game would see the mesh from various angles, it’s crucial to consider all viewpoints, not just one.
Additionally, as someone pointed out in the comment section, this process assumes absolute values. To ensure your values are positive, simply wrap an Abs() function around them.
For instance, if we encounter assets from different angles, such as full frontal, full side view, or full top view, depending on their positioning and rotation by the artist, we shouldn’t only use one angle (the diagonal) for calculation. By taking into account all angles, we can give thin or flat objects a more realistic chance of being accurately measured. We collect all these values and calculate the mean as the input value.
In hindsight, it might be better to use the maximum of all angles. If the difference between the smallest and largest number is too large, the LODs will fade out too quickly.
In an ideal setup, if the assets are placed and scaled, whether it’s larger or smaller, or if the field of view is wide or small, the game engine should compensate for these factors accordingly.
pseudo code diagonal = ∛(0.075² + 0.157² + 0.167²) = 0.387m front = ∛(0.075² + 0.157²) = 0.312m side = ∛(0.157² + 0.167²) = 0.375m top = ∛(0.075² + 0.167²) = 0.322m mean = ((diagonal + front + side + top) / 4) = 0.349m CalculateDistance(inSize=mean, inScreenSpacePercentage=100, inFovDegrees=45.0, inVerticalResolution=1080): ratio = inVerticalResolution / 1080 # compensate for 4k or FullHD screens # distance to see the asset, top to bottom distance_to_object = (inSize * 0.5) / (tan(inFovDegrees * 0.5)) distance_by_screensize = distance_to_object * 100 / inScreenSpacePercentage max_distance = distance_by_screensize * ratio return max_distance