Search Unity

LOD for complicated models

Discussion in 'General Graphics' started by _alphaBeta_, Oct 8, 2015.

  1. _alphaBeta_

    _alphaBeta_

    Joined:
    Aug 8, 2014
    Posts:
    38
    Does anyone have any advice for implementing LOD for complicated models at the model level? By complicated I mean a model with several hundred children that have children of their own etc. The children import as distinct gameobjects each with their own mesh.

    The Unity built-in system for LOD seems to be on a per-object basis where you can specify different meshes for one singular object. In my case, however, I have a different model file for each LOD. I need a good amount of the children to remain distinct since some animate and rotate, so I can't just flatten the model into one giant mesh. This doesn't seem like it would fit in well with the built-in system unless I'm not understanding it correctly.

    The only way I can think to work this is manually. I'd create a single parent object and import each LOD file as a child. Using scripting, I can track the camera distance and enable/disable each LOD child as appropriate. I see a few issues with this, however:
    1. Scripts on the overall parent of the object need to reference children to manipulate them. If I have three potential individual LOD models let's say, I'd have to track references to all three LOD versions of any given object, no? Sounds like a pain.
    2. I haven't tried this yet, but I'm concerned about performance if every complicated model has three LOD versions of itself sitting in memory. Granted only one of them is active at a time, but I want to understand if this is going to cause issues down the road.
    3. Again, haven't tried it yet, but I'm also concerned about how quickly the models will switch LODs with a setup like this. I suppose if they're in memory, I should be able to disable one and enable another in a single frame without major problems, correct?
    I can't imagine I'm the first person to do this, but I'm really not finding examples or guidance on this. Squeezing this setup into the built-in system seems like a lot more work. If I understand it correctly, I'd have to take every object and extract each mesh from the overall corresponding LOD model and attach an LOD group component to each one, no? It would seem much easier to switch LODs at the model level rather than the object level, even if I need to code the LOD logic myself, which I don't think is a big deal.