# Linearly Decimating a Mesh Relative to an Object’s Distance From the Camera

This is pretty complex, and I am fairly sure it is impossible to create, but I will ask around anyway.

Basically, I am looking for a way to linearly decimate a mesh relative to an object’s distance from the camera. (see attached drawing)

Preferably, this would be best done with geometry nodes, although I’d use a drivers solution if that is most optimal.

Fig. A: Mesh’s average polygon size increases as it gets farther away from the camera.

Fig. B: To the viewer, every mesh’s subdivision/average polygon size looks the same (appears to be the same size)

Fig. C: But in reality, the average polygon sizes are different sizes, saving memory

PS. Sorry for the crude drawing; I think better drawing things out! ;)

If we had a Decimate node this would be trivial, but unfortunately it's not here yet. I drew a blank on implementing a setup with more than two levels, but if that's enough, we could take advantage of the fact that subsequent modifiers on the stack can act only on realized geometry, by only realizing instances that are sufficiently far away from the camera:

A more flexible method would be to implement a LOD system, with progressively simpler pre-made variations of an object getting instanced as the distance increases:

Update: Here's a setup with a simpler index selection method. It snaps the camera distance to multiples of a certain number (our threshold), then divides those by themselves so we get a ladder of $$0,1,2,3...$$ for consecutive patches of equal distance, which corresponds to the indicies of the LODs, clamped at their max index so they don't loop. Simply put, it switches to the next index/simpler LOD every n-th meters from the camera, but it stops at the simplest LOD, dynamically. You just need to make sure your LODs are listed alphabetically in the collection.

• That second one has a smoother transition of decimated/simplified geometry; I like that. I'll try this setup to see if I can realize my goal with it. I'll keep you posted. If this works I'll approve the answer. Commented Nov 16, 2022 at 19:16
• @BlenderMaster15 Updated the answer with a simpler and more robust index selection method. Commented Nov 16, 2022 at 20:22
• Is there any way to use this so that there is only one mesh, and it changes LODs based on the distance from the camera? Commented Nov 16, 2022 at 20:44
• Like I said, I think we'd need a Decimate node for that; unless you want to make your own fake-decimate node like this or something similar: blenderartists.org/t/geometry-nodes-decimate/1387248/3 If you wanna do that, you could just use the setup from the first screenshot, separate by distance and "decimate" your instances inside GN. Commented Nov 16, 2022 at 20:50
• Ah! That makes sense. Commented Nov 16, 2022 at 21:14

Wouldn't this be a wonderful case for the node Map Range?

This could translate a certain distance of a given range into another, which corresponds to the number of instances in a collection.

Something like this:

(Blender 3.3+)