Level of Detail [addon]

Hello everyone,

I created a LOD system that also act as a Proxy system, and can also optionally back-up your mesh-data. It’s working as a mesh-data exchanging system available as a new panel in Properties>Mesh-data>Level of Detail, i will do a little presentation video tomorrow.

https://github.com/DB3D/Lodify/blob/master/Lodify.py

1
3
2
4

About the addon:

  • You can choose which lods you want to display in either the active viewport, the
    rendered view or the final render individually.

  • The LOD system use API properties stored within your object and object-data
    properties, that mean that once you created a LOD system for your object,
    the LOD(s) data will stick with it once you copy or append your obj to
    another file for example. Even to users who don’t have Lodify installed yet.

  • You can automatically search for lods according to their names, if you use a
    “Suzanne LOD 0”,“Suzanne LOD 1”,“Suzanne LOD 2” naming system or something similar.

  • You can use this LOD system as a data backup management system if you need to store
    your mesh data while working on destructive hardsurface modeling for example.
    You will find two ‘backup’ operators in the menu next to the LOD list.

  • Note that each LODs can have their own materials, as the material data is stored per
    meshes and not per objects.

  • Keep in mind that pointers are considered as data-users. You might want to clean
    leftovers pointers from deleted objects with the ‘cleanse data-block’ operator.

  • If you are animating via Modifiers (Bones for ex) the LOD system will work perfectly with
    your animation, assuming that the Vgroups are all assigned correctly for each level of detail
    (that’s why it’s more easy to create your lod from the final model, as the vgroup will
    automatically be assigned when you simplify the topology or decimate it).Shape Keys animation
    are not compatible with LOD.

  • Regarding the Rendered view automatic mesh-data switching:
    Note that Lodify will try to update the mesh-data on each “blender internal update signal”
    (called depsgraph update), so if you use a custom shortcut or pie menu that don’t send those
    “depsgraph updates” you might just want to click anywhere on the viewport to send a new one.
    (the default header shading viewport buttons will work 100% of the time for sure).

  • The addon was not made with linking from external blends in mind.

  • render.interface_lock will be enabled with this addon, this can be disable in the options (but expect some crashes if removed)

About the addon python code:

  • This addon basically act as a big mesh-data exchanging system where i exchange mesh data
    according to booleans stored in ui-lists.

  • As i’m drawing inside object-meshdata and i’m constantly switching the active mesh,
    ‘lod_original’ pointer is used as a constance, and is stored in object properties of
    all mesh-data owners. if you need to work with lodify api, always use this constance
    if not None. object.data is simply not reliable (-> ‘true_mesh_data’)

  • All the Lod-switch is done via a fct on each depsg udpate, (->‘analyse_and_exchange_data’)
    the code just analyse the ui-lists of all objects, if list exist and if boolean filled,
    the mesh-data is exchanged or restored accordingly.

  • Due to a severe blender crash, while in rendered view, if data is changed from a fct in a
    depsgraph, it will crash blender back to desktop instantaneously. To counter that, if user
    in rendered view and changing rendered boolan, the view will be toggled back and forth.
    You can experience this bug for yourself if you delete ‘toggle_shading’ in lines 825 and 827.

(i did my best so that the addon respect blender native UI)

Annotation 2020-04-26 192613

Tutorial

48 Likes

Hello, today I tried this add on and it is great. This is one of the reasons why I love blender (because of people like you) it has an awesome community and keeps developing the program and making it better. I have a suggestion on how to make this even better. I’m not sure how difficult it would be. To create simple presets of the LOD like box, plane. But it is great as it is really handy for display performance.


Thank you for this add on :slight_smile:

5 Likes

I may work on automatic LOD generation later :slight_smile:

6 Likes

This is really awesome. It’s very easy to set up and works great as a proxy system for using low-resolution meshes in the viewport and high resolution meshes in the render.

Is it possible to automate the LOD based on a user-configurable distance to the camera? This would allow us to do large vistas where objects close to the camera get rendered with LOD0 models and those further away get LOD3 or LOD4.

Thanks for posting! Hoping to see this develop into a full LOD system!

** Also, just realized that you’re the author of the Scatter tool. We purchased that on the Blender Market. Fantastic tool. Now makes sense why this proxy tool looks so familiar. :wink:

Distance LOD is inside your plans?

1 Like

If it can within a particle system yes, otherwise no.
so maybe when the new particles types are up.

2 Likes

Very interesting approach.

I made a LOD driver system a while ago, maybe it could be some inspiriation for further development:
https://www.blendswap.com/blend/11108

1 Like

thanks for sharing.
it seem that the system don’t support custom geometry, is it ?

the problem with driving a Lod by it’s distance from active camera is lods in particle systems

Yeah, it’s auto-generating the mesh by using a driver on the decimate modifier, so I wouldn’t recommend using it on e.g. character, where you want to preserve a certain geometry.

Awesome add-on! The view-based LOD selection is very easy to implement using handlers looping over through all the objects with LOD enabled and selecting the appropriate LOD level based on distance to viewport camera. Could be a great improvement for that!

2 Likes

yeah but how do you handle instances from particle systems ?
distance LOD switching could be extremely useful for creating forests for example, the only problem is that the current hair instancing solution don’t allow for much flexibility

1 Like

You can’t really do that inside one particle system through Python, it has to be homogenous in terms of the objects it displays. However, you can still set correct lods if the particle emitter itself is long away from the camera and its global “bounding box” (you need to calculate that) defined by how far the particles distribute from the emitter. So, in case of having different particle systems on the screen, that’d help to choose lods for them. But proper distance based lods are not possible in terms of smooth transition of particle instances from camera to the far clipping plane, sadly.

2 Likes

the problem is that blender seem quite instable when changing mesh data while cycles is in rendered view/about to prepare a new render :frowning:

1 Like

Quick update:

  • Added new batch operations functionality, batch enable/disable assets LOD system or change status by LOD name ending

Annotation 2020-05-08 194522

  • Added a new mandatory mode, to lock the interface while cycles is rendering. it seem that it’s causing unexpected behavior, cycles really don’t like mesh-data being exchanged while he is working …

Annotation 2020-05-08 194535

Commited on the Github link above

4 Likes

This looks great, I am going to test it on a heavy textured scene!!

Do you think you will be able to set a level of detail for HDRI sky textures also?

It can be great to have a 1k resolution sky HDRI texture for test renders, and a 4k or higher “Level of detail” for final render?

2 Likes

Right now It’s for meshes

1 Like

Hmm, weird thing but I can’t see Level of Details in 2.90. It has been installed from preferences > addons, but still no luck.

Tutorial now available on my youtube channel

6 Likes

I had the same thought, as LOD is used a lot in this case. It will save a lot of data for big scenes where far distant models don’t need so much data

Couldn’t a gradient with object group solve that? So the darker a gradient step it will take a different model. But thinking about it. We can’t control them like that. We could setup different particles setup based by distance. But that would mean lots of work if you have a big variation in models. I gies everything nodes could do this job as it can work with real objecr