guillaumechereau / goxel

Goxel: Free and Open Source 3D Voxel Editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Triangle count is super high

jerobarraco opened this issue · comments

When importing a simple object to unreal i noticed that the triangle count is very very high. even for simple objects.
it seems to me that there is no optimization being done when exporting.

Yes this is an issue at the moment. It would be nice to integrate a mesh optimization step in the export code, maybe there are open source libraries doing that?

i hope there are. i would bet there might be. specially since your code seem to be C.
I think vengi/voxedit did something similar.

on a similar note. not sure if i should open a new ticket:
some of the triangles overlap with each other and result in some kind of Z fighting.
this is a problem when using Nanite on unreal. the light renders with problems. also has issues due to overrendering (forgot the word).

i found this one has c and cpp interfaces. https://meshoptimizer.org/

i tried the utility called gtlfpack unfortunately it does some weird stuff to the gltf (like putting part of it in a bin file).
and unreal does not recognizes the format.
i tried using gltf glb and all the flags individually and together.

i would really like to ask if you do implement some optimization to have it as a export flag so i can turn it off/on depending on the asset to avoid issues like this and others.

The glTF export definitively needs more work. I already changed the code a bit to at least use a single mesh per layer, but for the moment this is still using several primitive per mesh.

Meshoptimizer looks interesting yes.

Can you open a new issue specifically about the overlap you see? If possible with a screenshot because I am not sure what the issue is.

thanks a lot.
meshoptimizer seems promising, maybe using it as a library would be more flexible (and also a bit more work).
unreal does not imports it as is. i needed to use the flag -noq otherwise it fails to import.
zeux/meshoptimizer#584

if you ever implement this please make it optional or add a way to set the flags to ensure compatibility. it could make the tool unusable for me if i can't import.

it reduced the number of vertices but not the number of triangles

org
image

packed
image

though something better should be out there..
unreal auto lod seems to get it around 500 each. but it's really annoying to set it up every time i import a mesh (which includes when i'm modifying it)
image

on another news the overlapping vertices seems to be an issue with ue auto lod :/ ( i will open a new issue if i do find is something related with goxel)

lod 0
image

lod3 (the one i use as the default)
image

I just pushed a first change that uses meshoptimizer to cleanup the mesh a little before export. For the moment this is not doing any advanced simplification, but should already result in better topology. Not sure if that would improve the import in UE though.

Also added an new option to simplify the mesh. With simplification Goxel will attempt to remove as many vertices as possible before exporting. All of this is still quite experimental.

awesome! I will try them both whenever i get the chance :) Thanks a lot!

As i feared the "simplify" option messes with the colors.
this is with the simplify option
image
image

this is without it but with build 68
notice that the vertex and triangle count is exactly the same
image
image

both of the above uses texture mode since vertex colors still crashes ue.

this is build 51 without the material set just for vertex count comparison
image

also i just noticed that v68 when importing the file the meshes have the appropriate name of the layer. (as opposed to build 51 which have weird names "node-something"(