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

Triangle count is super high #315

Closed
jerobarraco opened this issue Jul 18, 2023 · 20 comments
Closed

Triangle count is super high #315

jerobarraco opened this issue Jul 18, 2023 · 20 comments

Comments

@jerobarraco
Copy link

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.

@guillaumechereau
Copy link
Owner

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?

@jerobarraco
Copy link
Author

jerobarraco commented Jul 20, 2023

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).

@jerobarraco
Copy link
Author

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

@jerobarraco
Copy link
Author

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.

@guillaumechereau
Copy link
Owner

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.

@jerobarraco
Copy link
Author

jerobarraco commented Jul 21, 2023

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

@jerobarraco
Copy link
Author

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

@guillaumechereau
Copy link
Owner

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.

@guillaumechereau
Copy link
Owner

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.

@jerobarraco
Copy link
Author

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

@jerobarraco
Copy link
Author

jerobarraco commented Jul 25, 2023

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"(

@guillaumechereau
Copy link
Owner

Sorry for the late reply. Do you have the gox image? I am looking at this again but I cannot reproduce the issue currently.

@jerobarraco
Copy link
Author

i think is this one. sorry the delay.
Char18-Head.g.zip

@guillaumechereau
Copy link
Owner

OK I made some changes to try to fix this bug. Seems to work on your model, when I open it with blender.
I also change the "simplify" from a checkbox to a float input from 0 to 1, so that we can control the algo a bit.

image

@jerobarraco
Copy link
Author

jerobarraco commented Jan 9, 2024

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.

@guillaumechereau
Copy link
Owner

Ah that's right, I didn't see that... I'll check a bit more.

@jerobarraco
Copy link
Author

btw, the triangle count has definitely improved with the new simplification. thanks a lot!

@guillaumechereau
Copy link
Owner

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?

@jerobarraco
Copy link
Author

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.

@jerobarraco
Copy link
Author

Screenshot_20241019_174751
Screenshot_20241019_174845

this seems to be working pretty well on 1.51 thanks a lot!
i feel really uncomfortable closing the issue. but i assume that's what you'd prefer.

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

No branches or pull requests

2 participants