Objects are transparent along their edges

I have tried so far all options and combinations to avoid transparent edges, but whatever approach I choose, the objects I remesh are transparent along their edges.

The mesh I am processing is raw data / photogrammetry based and I followed this

and experimented with the different settings without any success.

I could get rid of the alpha channel on the UV, but this is not really a solution for the problem.

The solution should be very simple. I just need the UV shells to be strechted a few pixels, but the stretch importance does not seem to have any affect.

I helped myself out for the time beeing, with a Blender python script I created to work around this issue.
Maybe someone else finds this useful.

import bpy
import bmesh
from mathutils import Vector

# Set the desired pixel decrease
pixel_decrease = -1 / bpy.context.scene.render.resolution_x  # Normalize to UV space

# Get the active object and its mesh
obj = bpy.context.active_object
mesh = obj.data

# Check if the object has UV maps
if not obj.data.uv_layers:
    print("Error: Selected object has no UV maps.")
else:
    # Get the active UV map
    uv_map = obj.data.uv_layers.active

    # Use BMesh to work with mesh data
    bm = bmesh.new()
    bm.from_mesh(mesh)
    uv_layer = bm.loops.layers.uv.active

    # Function to find UV islands
    def get_uv_islands(bm, uv_layer):
        uvs = {}
        for face in bm.faces:
            for loop in face.loops:
                uv = loop[uv_layer].uv
                vert = loop.vert
                if vert not in uvs:
                    uvs[vert] = []
                uvs[vert].append(uv)

        visited = set()
        islands = []

        def bfs(vert):
            queue = [vert]
            island = set()
            while queue:
                v = queue.pop(0)
                if v not in visited:
                    visited.add(v)
                    island.add(v)
                    for edge in v.link_edges:
                        other_vert = edge.other_vert(v)
                        if other_vert not in visited:
                            queue.append(other_vert)
            return island

        for vert in uvs:
            if vert not in visited:
                island = bfs(vert)
                if island:
                    islands.append(island)

        uv_islands = []
        for island in islands:
            uv_coords = []
            for vert in island:
                uv_coords.extend(uvs[vert])
            uv_islands.append(uv_coords)

        return uv_islands

    # Find UV islands
    uv_islands = get_uv_islands(bm, uv_layer)

    # Decrease UV coordinates of each UV island by pixel_decrease
    for uv_coords in uv_islands:
        # Calculate the centroid of the UV island
        centroid = Vector((0.0, 0.0))
        for uv in uv_coords:
            centroid += uv
        centroid /= len(uv_coords)
        
        # Scale UV coordinates towards the centroid
        for uv in uv_coords:
            direction = uv - centroid
            uv += direction.normalized() * pixel_decrease

    # Update the mesh with the new UV coordinates
    bm.to_mesh(mesh)
    bm.free()

    # Ensure changes are updated
    mesh.update()

It’s not perfect, but it closes most of the gaps.
-1 pixel works best, without affecting the mesh too much

If someone has a proper solution or another idea I could try inside InstaLOD, that would be much appreciated!

1 Like

Hello @ignobilis and welcome to our community!

Thank you for your post and for providing the python script. I’m glad you were able to arrive at a solution.

The first suggestion would be to increase the Gutter Size in Pixels setting. If you have already tried this, could you please provide some screenshots and a mesh file for us to test internally? If you do not wish to share this publicly, I can initiate a PM so that you can send the data privately.

Thanks!

Hi Pixby

thanks a lot first of all, looking into this.
I did try the Gutter Size and went into both directions 1 → 30 with same result:

Here a screenshot of the object. The black edges are transparent, when looking against the horizon out of the renderer.

And here a quick’n’dirty render of the object

The black edges are transparent

Here the mesh after optimization:
test_LOD.zip (5.1 MB)

My settings as zipped json
my_remesh-settings.zip (1.8 KB)

Thanks!

1 Like

I did experiment a little more and this is a common problem for me. It is not unique to the initial mesh/object.
Regardless which object type I import and then postprocess inside InstaLOD - as soon I do the export, the textures/mesh gets messed up. I can reproduce this with any material. I have tried .fbx, .glb/.gltf so far as import and export methods.

I always end up with transparent edges.

Here another example:

Remeshed object inside InstaLOD

Same object (exported and rendered)

Am I doing something wrong maybe inside the material settings?

Hello @ignobilis,

I noticed you attached the processed mesh but not the original. Would you be able to provide the original mesh so that we can test it internally? If you do not wish to share it publically, I can send a PM.

Thanks!