LOD in game

LOD stands for Level of Detail. It is used in many videogames. It is quite simple: There are usally 2-4 meshes of an object, ranging from high quality to low quality. As you move away from the object, you first see the highest quality mesh, than far away you see lower quality. Is there a way to do that in blender. Games with complicated scenes would be sped up dramatcally.

In a way, yes, but it will take some work.
others correct me if im wrong.
you could put near sensors set at different distances with a replace mesh actuator atached to each one so that as the camera got farther away each mesh would be replaced by another less detailed one that you made and the opposite as the camera got closer.

hopefully thats helpful.

that seems to me like it would work…wait, a bit off topic, but arent you one whos apparently responsible for those bad threads?

Follow this link:
http://www.blender.org/modules/documentation/pydoc_gameengine/PyDoc-Gameengine-2.34/KX_SCA_ReplaceMeshActuator.KX_SCA_ReplaceMeshActuator-class.html

It points to the python reference which contains an LOD script example. You have to apply this logic to all objects that should support LOD. As you see it is up to you how many LOD meshes you have and how they look like.

I hope this helps

Damn it Monster,

I was just writing a script, lol.

you must do that in python with object list and specific names.
if you do that in logic brick it will be so big.

just refresh the script all the time and verify distance between object and camera and change in function of the distance

I couldn’t get it working. Could someone post a .blend?

I can’t post but do it like this:

  • cut and paste the python script from the above website and place it in an text file “LOD.py”.
  • go to blender
  • start with default scene
  • enter the text editor
  • open the file LOD.py
  • enter 3D View
  • rename the object “Cube” in the center of the screen to “mesh” ( in link and materials Panel)
  • go to layer 2
  • add a ISOSphere (sub 1) name the meshOBmesh.Lo”. (in link and materials Panel)
  • add a ISOSphere (sub 2) name the mesh “OBmesh.Mid”.
  • add a ISOSphere (sub 3) name the mesh “OBmesh.Hi”.
  • go back to layer 1 and select “mesh”
  • add logic bricks to move the object “mesh” around (keyboard -> motion etc.)
  • add an always sensor --> python controller with “LOD.py” --> EditObject actuator called “LOD.OBmesh” set to “Replace Mesh”
  • switch to wireframe
  • start the engine
  • add an always sensor –> python controller with “LOD.py” –> EditObject actuator called “LOD.OBmesh” set to “Replace Mesh”

what do you replace it with (what do you type in the ME: box)

I still tired and failed. Very strange. No .blends, suprising that no game has already used it.

No need to place a name here. The script will change the name anyway.

I never used it as it seems a lot of extra work. I have no game were it is worth. Maybe in a later stage.

I was thinking about having a “LOD scene”. My idea was to have a scene with high resolution meshes. The camera clip ends after 10. A background scene uses lower detailed meshes with the same camera control. The camera clip starts at 10.
Experimenting with this method showed some problems:

  • it is slow! because you have two scenes with nearly the same content.
  • as the border is the clipping plane and not the complete object the high and low detailed meshes do not fit which results in strange output
  • the scenes seemed not to be synchonised (one was 1 frame behind)
    The benefit would be
  • you have a smaller z-buffer range for the high resolution scene. This prevents the famous flickering (a plane from the back shows partly through a scene in front)
    +everything is LOD; no dealing with every little object setting up scripts

“LOD scene” was not worth

I guess clever game moldling is the best medicine. Know when to decimate.

Got it working here, thanks!
At first I had some problems with the copied script´s tabs but got it OK now.

Looking to the future

The ogre graphics engine has automatic LOD.
so when the plugin is finished you might not have to worry about this kind of thing for the blender engine any more.

ogre info link

Does anyone know if Blender/OGRE will be able to do seemless scene transitions? I mean like high end games where you just go where you want and the engine loads new scene elements in the background.

I would guess that since Blender doesn’t do it now and OGRE isn’t a game engine the answer is no. Is this a considered feature to be included or added at a later time?

You could always use python to link objects to the scene you are going to and then load the scene.

Man! That will be needed! (Well atleast I´ll make use of it…)