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
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)
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
this is without it but with build 68
notice that the vertex and triangle count is exactly the same
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
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"(
Sorry for the late reply. Do you have the gox image? I am looking at this again but I cannot reproduce the issue currently.
i think is this one. sorry the delay.
Char18-Head.g.zip
if this is in i will test it right away! thanks!
though in that image: the left head. bottom right of the right eye has a quirk.
Ah that's right, I didn't see that... I'll check a bit more.
btw, the triangle count has definitely improved with the new simplification. thanks a lot!
Thanks. I was unable to reproduce the quirk in the eye. I wonder if my screenshot was maybe using the wrong export. Do you still see the issue?
i haven't seen this lately. if i come across it i'll open a new thread to not clog this ticket which seems to be a different issue.
i did had trouble with some meshes butchering the colors (as if the triangles were simplified too much), but i'll report back if i find it happening on the latest build.