OSArch Community

Blender terrain mesh with image - exporting to FBX shenanigans

  1. C

    I'm attempting to replace my current use of Infraworks with Blender, and I've almost reached the output I want but I'm struggling with what is really the final hurdle.

    To keep it simple, I have a large terrain mesh in blender, which I have successfully UV-unwrapped and textured with my image. So in Blender, everything looks great.

    The problem starts because I want to export the mesh+image to FBX so I can use it as a reference in various Navisworks scenes. I have actually done this - but there is an issue: because the FBX is one large mesh attached to one large image, Navis destroys the texture quality. I can change settings to make it look much better - but I don't have the power to change every user's settings - so this isn't an option.

    I need my FBX export to work in the same way that Infraworks handles it. Infraworks (at export) tiles both the mesh and the image (say into a 10x10 grid). This way, each FBX texture is much smaller, and so Navisworks doesn't feel like it has to destroy the resolution.

    I have a script that I found to cut my mesh into grids:

    
    import bpy, bmesh
    
    from bpy import context
    
    from  mathutils import Vector
    
    # bounding box helper methods
    
    def bbox(ob):
    
        return (Vector(b) for b in ob.bound_box)
    
    def bbox_center(ob):
    
        return sum(bbox(ob), Vector()) / 8
    
    def bbox_axes(ob):
    
        bb = list(bbox(ob))
    
        return tuple(bb[i] for i in (0, 4, 3, 1))
    
    def slice(bm, start, end, segments):
    
        if segments == 1:
    
            return
    
        def geom(bm):
    
            return bm.verts[:] + bm.edges[:] + bm.faces[:]
    
        planes = [start.lerp(end, f / segments) for f in range(1, segments)]
    
        #p0 = start
    
        plane_no = (end - start).normalized() 
    
        while(planes): 
    
            p0 = planes.pop(0)                 
    
            ret = bmesh.ops.bisect_plane(bm, 
    
                    geom=geom(bm),
    
                    plane_co=p0, 
    
                    plane_no=plane_no)
    
            bmesh.ops.split_edges(bm, 
    
                    edges=[e for e in ret['geom_cut'] 
    
                    if isinstance(e, bmesh.types.BMEdge)])
    
    bm = bmesh.new()
    
    ob = context.object
    
    me = ob.data
    
    bm.from_mesh(me)
    
    o, x, y, z = bbox_axes(ob)        
    
    x_segments = 10
    
    y_segments = 10
    
    z_segments = 1
    
    slice(bm, o, x, x_segments)
    
    slice(bm, o, y, y_segments)
    
    slice(bm, o, z, z_segments)    
    
    bm.to_mesh(me)
    
    bpy.ops.object.mode_set(mode='EDIT')
    
    bpy.ops.mesh.separate(type='LOOSE')
    
    bpy.ops.object.mode_set()
    

    This works great. But each mesh part is still UV'd to the larger image. I've played around with pre-tiling my image prior to bringing it into Blender - but manually UV-wrapping 100 meshes with 100 images is going to take too long to make it worthwhile.

    I've also looked into baking - which seems like it's way more difficult than it ought to be in base Blender. The issue I have here is that for my bake to work, I have to bake to an image with the same resolution as my original (as far as I understand) - which results in 100 images of large size.

    I hope that maybe there is some setting in the Bake which I've not found from my googling - or maybe a slightly different approach that people who use Blender regularly might be able to point me towards. Thanks

  2. C

    paging @magicalcloud_75 who seems to have looked at similar issues in the past (only 2 years ago :D)

  3. C

    I stumbled upon UDIMs which sound like exactly what I need. I've set them up such that each mesh 'segment' is mapped to each UV tile - however since UDIM functionality is fairly new it seems like the FBX exporter plug-in hasn't considered them - so now when I export to FBX I get no texture information at all.... sad.

  4. C

    I think using UDIMs could even negate the need for splitting the mesh at all, as it works even if I don't split the mesh into segments - but in either case the FBX export doesn't work, so it's probably a case that the FBX exporter needs to be updated, and considering this is quite a niche requirement I won't get my hopes up.

  5. M

    My experience is the same. Navisworks kills resolution. I am still not able to get nice quality FBX ootb.

Login or Register to reply.