LOD change by distance, not screen height?

So the current lod system, where the lod is set by changes in screen height, only works when the objects are basically equal in all dimensions or taller. This is rather limited and leads to unpredictable behavior in other cases. For instance: My game has hundreds of sections of train tracks that are long and almost flat. Compound that with the fact that they can be viewed at various heights, and I end up with tracks that pop in way off in the distance while the ones close up are still invisible.

How do I set this up to switch by discreet distances rather than relative height? Since this is such a basic thing and has been done for years in pretty much all other engines, it would be nice if there was just selector in the script to switch between height and distance.

2 Likes

Very good question.
There are many other problems with this solution:

It is useless on large objects because once it fills the vertical image diagonal, it is no longer possible to operate with additional LODs. In Unreal at least there is the possibility to increase the vertical value above 100. I don’t understand why this is limited? What is the logic in taking away this flexibility from developers?
Then there’s an even bigger pain if you have different aspect ratios for the display, then as many aspects as many ways the LOD behaves.
This has been a constant problem during development, by the way, that running from a test in the Editor will have no effect on the native device or on a different resolution.
The other question is why you can only specify vertical, why not horizontal, let’s say in your example, if an object is more horizontal then “vertical” LOD is useless.

I found this third party solution, but I haven’t tested it yet:

Surprised to see there appear to be no solutions for this. Does anyone know of a custom approach, perhaps?

What about a script that measures the distance itself and enables/disables the renderers accordingly? How would this compare in performance to a LOD group component?

Im not sure honestly, but its what i do when requiring more than an LoD offers.

Oh actually, there is this Culling Group API thing Unity - Manual: CullingGroup API, seems to fit the use case

1 Like

Found another interesting thing: it seems one can make LOD behavior independent of object size by simply resetting the object size to 1:

8511689--1134236--upload_2022-10-13_20-10-18.png

There is still no way to ensure a specific distance for culling, as that apparently may vary depending on camera, but at least it will make objects behave the same way if you want them to.

Edit: Interestingly, there appears to be no way of doing this from code - it seems to be custom functionality of the LOD Group component UI.

Edit 2: There seems to be yet another way of doing this! Unity - Scripting API: Camera.layerCullDistances

We are at three different approaches now. Hopefully this thread helps centralize that information.

1 Like