Take the 2-minute tour ×
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It's 100% free, no registration required.

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!

share|improve this question
    
I am not sure if this is possible outside of the game engine. –  RolandiXor Feb 24 at 19:25
add comment

1 Answer

up vote 3 down vote accepted

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

share|improve this answer
    
That might work nicely with the Decimate modifier too.. –  gandalf3 Feb 24 at 21:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.