Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a manifold extension to glTF #422

Closed
elalish opened this issue May 2, 2023 · 6 comments · Fixed by #428
Closed

Build a manifold extension to glTF #422

elalish opened this issue May 2, 2023 · 6 comments · Fixed by #428
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@elalish
Copy link
Owner

elalish commented May 2, 2023

Considering that Manifold handles arbitrary mesh properties like normals and UVs, it would be nice to be able to round-trip this type of material data through a file format losslessly. This is not generally possible, as even indexed files like OBJ or glTF must be exported as non-manifold when they contain multiple materials (or even sharp corners) as GPUs require the vertex positions to be duplicated for any vertex properties that don't match. Relying on geometric checks (verts having identical positions) to reassemble the manifold will often work, but is unreliable in general.

It appears that a glTF extension is possible to make that will encode this manifoldness data, and at very little size cost, by using their concept of sparse accessors. I'll write up this extension and propose it to Khronos (since I work with them for my day job anyway), but as far as Manifold is concerned, the work will be to make a reader and writer of this extension, proving that it works.

I think it'll also be a good opportunity to show off #394 by making a small web tool to upload a GLB and download the manifold version of it (or show that we can't fix it automatically), which will hopefully help with problems like #91 (comment)

@elalish elalish added the enhancement New feature or request label May 2, 2023
@elalish elalish added this to the v2.2 milestone May 2, 2023
@elalish elalish self-assigned this May 2, 2023
@elalish
Copy link
Owner Author

elalish commented May 5, 2023

Here's the glTF extension draft: KhronosGroup/glTF#2286

@elalish elalish mentioned this issue May 9, 2023
@fire
Copy link
Contributor

fire commented May 10, 2023

@elalish If I wanted to support this in Godot Engine should I implement this extension? How does it degrade?

I unhappily wasn't able to integrate your manifold library into Godot Engine in a reasonable time.

@elalish
Copy link
Owner Author

elalish commented May 10, 2023

If you can explain your use case I'll be able to give you a better answer. How do you plan to use manifold meshes?

Are you still interested in integrating manifold into Godot, or has that been blocked? Anything I can do to make it easier?

@fire
Copy link
Contributor

fire commented May 10, 2023

One of the problems with using the manifold library is requiring input manifold meshes.

If I can keep a chain of meshes that are manifold in gltf form, I can keep the chain all the way to the output. Starting from the cad / 3d modeler, imported into godot engine (triangulated), and then csg merge, subtract and intersect operations, to the resulting mesh which also be used for the input of this chain.

I rejected using a system where the non-manifold meshes are voxelized with openvdb and then forced into manifold structure.

@elalish
Copy link
Owner Author

elalish commented May 10, 2023

Then yes, this is exactly the kind of workflow I was envisioning this glTF extension would be useful for. This way a manifold mesh can be marked as such and transmitted without loss. Of course it doesn't solve the hard problem: many meshes (including CAD) are not even close to manifold and fixing them is often non-trivial. But at least we now have the MeshGL.Merge() function that will fix them if they're within tolerance of being manifold (like many STLs, for instance).

@fire
Copy link
Contributor

fire commented May 10, 2023

I think from a point of view of a user, I can have a scene that enforces manifold input. As long as the chain is unbroken, I get a manifold output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants