How to merge regions of faces that share edges into a single face, for cleaning scanned 3D models

A similar question to mine is @carson’s asking if it is possible to dissolve faces/meshes in three.js. (ref: How to use three to dissolve Faces/Meshes like in blender)

Thanks to @Mugen87 for the clarification, but isn’t there any way possible to work around this problem?

In my app, users are allowed to upload raw files that were 3D scanned. They are not optimized for the web and I have checked all possible ways to optimize them.

No texture needed, I used MatcapMaterial() and eliminated the need for a light source, no shadows, and finally, I used MergeVertex in the BufferGeometry() to reduce the vertices count.

I have also implemented @donmccurdy’s gltf-transform in the backend and activated the MeshoptSimplifier to have the best result, yet there are many faces!

Yes, I don’t have that much vertices in the scene, but there are too many faces! Once there are many elements in the scene, the framerates directly drop.

Using Limited Dissolve with Blender also creates problems (too many Ngons that miss with the light in real-time rendering), but there is a simple fix in there. Using the tris to quads tool solved the problem.

Would it be possible to create a wasm version of Blender’s code that would work on the web? Like this example, and its Github Repo. The original version was created in C.

Just in case, here is a link to Blender’s source code in github and the source code in the official website

1 Like

When you go to merge your vertices, are you deleting all other attributes like uv, normal, and color?
It includes all attributes in the merge determination so if any of these attributes vary they will prevent the collapse of vertices, so it’s best to delete everything but position first… iirc.
geometry.deleteAttribute(‘normal’)
geometry.deleteAttribute(‘uv’)
geometry.deleteAttribute(‘color’)

and r.e. running blender on the web, that would be a no… however you can drive/script headless blender on the server to do scripted operations on meshes.

Not exactly. I don’t need the UV’s anyway and/or vertex colors. I only have normals and positions.

I am a bit interested in trying to run the headless scripts. Can you describe that a bit more, please?

Blender is scriptable via python. Pretty much anything you can do in blender, you can recreate the operation in a .py script in blender.
Blender can also be run “headless” with no UI, like a commandline tool… and you can pass a script to run in the commandline parameters. so you could for instance use node to generate a configuration .py script that calls blender from the commandline, loads up a default template environment for whatever operation you’re doing… and then imports your gltf, which u then run the operation on, and export back out.

ChatGPT can probably walk you through the process.

1 Like

Thanks a million for your explanation @manthrax

Using Blender headless scripting features is going to be very heavy for the server. The memory it takes + processing time for every file is quite too much for the server.

I may go ahead and try to find some other ways to reduce the face count. What I aim for now is using low-level code (C, C++, or Rust) and find a way to use it with a web assembly.

Any additional comments will be heavily appreciated :heart:

…aaand:
This one is more of a mesh optimizer/crusher but also can do reduction:

1 Like

If glTF Transform (using Meshoptimizer internally for simplification, essentially the same as gltfpack in this regard) is not reducing the vertex/face count as far as you need or expect, then this might be a deeper question about the input geometry or parameters. In general, it should be possible to collapse a topologically-connected input geometry to nothing with the most aggressive settings.

Could you share an example of the geometry you’re having difficulty simplifying? There are some known limitations and workarounds possible.

1 Like

You’re not looking for this?

Thanks for the suggestion! :heart:

I can’t see how can that help. What I am looking for is a simplification method!

Thanks a lot for the reply. I can’t share those files publicly, but I have sent them via email so that you can check them.