Search Unity

LOD change by distance, not screen height?

Discussion in 'Editor & General Support' started by gevarre, Apr 25, 2018.

  1. gevarre

    gevarre

    Joined:
    Jan 19, 2009
    Posts:
    132
    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.
     
    marcospgp likes this.
  2. Hamu_Art

    Hamu_Art

    Joined:
    Apr 24, 2020
    Posts:
    15
    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:
    https://assetstore.unity.com/packages/tools/utilities/optimizers-122247
     
  3. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    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?
     
  4. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Im not sure honestly, but its what i do when requiring more than an LoD offers.
     
  5. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    Homicide likes this.
  6. marcospgp

    marcospgp

    Joined:
    Jun 11, 2018
    Posts:
    194
    Found another interesting thing: it seems one can make LOD behavior independent of object size by simply resetting the object size to 1:

    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! https://docs.unity3d.com/2023.1/Documentation/ScriptReference/Camera-layerCullDistances.html

    We are at three different approaches now. Hopefully this thread helps centralize that information.
     
    Last edited: Oct 13, 2022