6
$\begingroup$

I'm trying to model a city, and I was wondering if Blender somehow supports "level of detail", i.e. something like this:

  1. I create multiple versions of the same buildings that differ by polygon count (low-poly model, medium-poly, high-poly...).
  2. When I hit render, Blender will automatically choose between these versions based on distance to the camera, so that far away buildings use low-poly models, and nearby buildings high-poly models.

Does Blender support this directly? If not, can it be done via scripting?

For further clarification, I'm not trying to build a game, I just want to render some scenes in different parts of the city. Thanks in advance!

$\endgroup$
1
  • $\begingroup$ I am not sure if this is possible outside of the game engine. $\endgroup$ Commented Feb 24, 2014 at 19:25

1 Answer 1

3
$\begingroup$

The Level Of Detail settings in Blender 2.7 will be only available in the game engine.

Someone else had an approach to control the subdivisions of a multires modifier using a driver and use the distance from cam to an object.

enter image description here

See this Blog post detailed information and demo file.

It does not support switching different meshes only subdivision nor LoD for different textures.


My approach would be to have different Objects / Meshes parented and calculate the distance from camera to each object. For a quick test I parented a lores version to a higher mesh version of a model.

Like so: enter image description here

Depending on a distance threshold the visibility of the lores or the hires parent is easily controlled by a script:

import bpy

threshold = 9

scene = bpy.context.scene
camera = scene.objects["Camera"]
cam_pos = camera.location
print(cam_pos)
for ob in scene.objects:
    print( ob.name )
    if ob.name.startswith("Cube.LowRes"):
        d = cam_pos - ob.parent.location
        dist = d.length

        if dist > threshold:
            ob.hide = False
            ob.parent.hide = True
            ob.hide_render = False
            ob.parent.hide_render = True

        else:
            ob.hide = True
            ob.parent.hide = False
            ob.hide_render = True
            ob.parent.hide_render = False
        print( ob.location )       
        print( dist )

If you plan to use this with for an animated camera you could consider adding a bpy.app.handlers.frame_change_pre and call the script before each frame.

Demo file here

$\endgroup$
1
  • $\begingroup$ That might work nicely with the Decimate modifier too.. $\endgroup$
    – gandalf3
    Commented Feb 24, 2014 at 21:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .