Cyaoeu's bag of Blender tricks

Adding support for static mesh LOD export in Blender

Credits to Pavel Křupala for this method. Blender does not have LOD support for UE4 by default but this can be added easily. This method will allow you to create an Empty object named “LOD_(objectnamehere)” which you parent your static meshes to and end up with a single LODed static mesh in UE4.

We’ll accomplish this by editing the binary FBX exporter in Blender. You can find that in BlenderFolder\2.78\scripts\addons\io_scene_fbx, there’s a file called export_fbx_bin.py which is what you want. First save a duplicate of the file if anything goes wrong, then edit the file by searching for the row:


null.add_string(fbx_name_class(empty.name.encode(), b"NodeAttribute"))

Comment out the line


null.add_string(b"Null")

by adding a # before it so it looks like this:


#null.add_string(b"Null")

Then paste this:


if empty.parent is None and empty.name.startswith("LOD"):
    null.add_string(b"LodGroup")
else:
    null.add_string(b"Null")

The if line should line up with the previous line.

If Blender was open close it and open it again. Next in Blender create an Empty object and name it LOD_(objectnamehere). The important thing is that it has LOD in the beginning of the name. Next you need to parent your objects to this Empty. Note that the order you parent the objects is important, parenting them all at once won’t necessarily work. Parent the objects one at a time, starting with LOD0, after that LOD1 and so on. The order in which you parent these objects will have an effect on the final LOD ordering in UE4.

Then export the objects (including the empty) and you should up with a single static mesh with LODs. That’s it!

Here’s a simple script to create the empty and parent everything automatically. It assumes you’re naming things with _LOD0, _LOD1, _LOD2 suffixes in the object names.



import bpy

flip = 0                                                          
empty = bpy.data.objects.new("empty", None)
bpy.context.scene.objects.link(empty)
for obj in bpy.context.selected_objects:
    if obj.name.endswith("_LOD0"):
        LOD0 = obj
    if obj.name.endswith("_LOD1"):
        LOD1 = obj
    if obj.name.endswith("_LOD2"):
        LOD2 = obj
splitname = LOD0.name.split("_")
empty.name = "LOD_" + splitname[0]
bpy.ops.object.select_all(action='DESELECT')
LODArray = [LOD0, LOD1, LOD2]
for LOD in LODArray:
    LOD.select = True
    bpy.context.scene.objects.active = empty
    bpy.ops.object.parent_set()
    bpy.ops.object.select_all(action='DESELECT')