Exporting file almost doubles vertex count

GTA:V Modding with ZModeler3 discussion.
Post Reply
TomcattersVF31
Beginner
Posts: 111
Joined: Fri May 18, 2012 10:13 pm

Exporting file almost doubles vertex count

Post by TomcattersVF31 »

Hi,

I currently have a problem where I want to export a .yft with around 330k vertices. Upon Export I am hit with a 26mb file though. Upon re-import the model has almost twice as many vertices with some objects now being a group of several individual objects due to exceeding the vertex limit.

I can understand group them and then weld the vertices again to get the count down to the original (or very close to) count, but upon export it just happens again.

Any clue what could cause this?
TomcattersVF31
Beginner
Posts: 111
Joined: Fri May 18, 2012 10:13 pm

Re: Exporting file almost doubles vertex count

Post by TomcattersVF31 »

Ok additinal info: even export as .obj does the same. Exporting as .fbx actually works fine

https://imgur.com/a/yRr9kdj

One picture shows it all before export with 27k vertices, then upon re-import it's 48k and separated. I can simply weld them back together. No issue. But it won't "survive" the export for whatever reason.
User avatar
Oleg
Site Admin
Posts: 14990
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: Exporting file almost doubles vertex count

Post by Oleg »

can you delete everything and leave just one "round thing" in scene. then test the export with just this small object. Does it suffer the same issue? if it does, send me your .z3d file, I'll take a look and tell what exactly is wrong.

I assume the lowest screenshot is "before export" and it look OK to me. It's pretty strange to get vertices increase on export from ZModeler, most common issue when you get vertices increase upon importing model into ZModeler (due to split of vertices with respect to polygons UV mapping).
TomcattersVF31
Beginner
Posts: 111
Joined: Fri May 18, 2012 10:13 pm

Re: Exporting file almost doubles vertex count

Post by TomcattersVF31 »

Oleg wrote: Mon Apr 14, 2025 1:32 am can you delete everything and leave just one "round thing" in scene. then test the export with just this small object. Does it suffer the same issue? if it does, send me your .z3d file, I'll take a look and tell what exactly is wrong.

I assume the lowest screenshot is "before export" and it look OK to me. It's pretty strange to get vertices increase on export from ZModeler, most common issue when you get vertices increase upon importing model into ZModeler (due to split of vertices with respect to polygons UV mapping).
Thanks, I suspect it might something with the mesh, although I still don't understand why seemingly fine meshes/vertices break upon export.

This is the file and the mesh(es) that suffer the most are the "container" parts of the truck.
User avatar
Oleg
Site Admin
Posts: 14990
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: Exporting file almost doubles vertex count

Post by Oleg »

Well, this is a technical limitation actually. Geometry fragments in yft file are chopped to ~4K vertices bursts for parallel render in game engine. Your geometry object has a bad triangles ordering when triangles 1,2,3,4 are not a neighbors (sharing some common vertices), but are spread all around the geometry object randomly. So triangles 1,2,3,4 use absolutely different vertices on a mesh. Given that, when bursts are created they get triangles from random areas of the object and accumulate random triangles from here and there; then another burst starts and it does the same - random triangles from the mesh and random vertices from different areas. The pre-requirement for good optimization is to have triangles one next to another so they share vertices, perfectly to have consequent triangles so two vertices from previous triangle are used in the next triangle. This gives both geometry usage optimization and on-GPU vertices cache optimization.

What can be done now on your mesh? You need to make triangles go in groups so they represent some patches of surfaces instead of being total random. To do this, you can use an in-place detach method. The detach tool with all options toggled off (no "new object", no "drag", no "keep original"). Thus, when some polygons fragment is selected and "detached" this way, the selected group of triangles separates (together with vertices) from the rest of the object and then attached back. Thus, the group of triangles will the the last in a set of triangles, and the vertices they use will be the last in a set of vertices.
In particular, you can make a long walk all around your geometry object and make this select-detach-hide; select-detach-hide steps. To speed up, you can use Select\Element or Select\Separated tool to make selection of interconnected triangles to be in a group. Its a long way but that's the only way I see so far. You can select patches to approximately 1K-2K triangles in total (from different areas no problem here) before detaching. It might take some time, but you will get a suitable result.
TomcattersVF31
Beginner
Posts: 111
Joined: Fri May 18, 2012 10:13 pm

Re: Exporting file almost doubles vertex count

Post by TomcattersVF31 »

Still learning something new after 15 years hahaha


Thanks, it worked. Would have never figured this out on my own!
User avatar
Oleg
Site Admin
Posts: 14990
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: Exporting file almost doubles vertex count

Post by Oleg »

same here. it took me about 4-5 times to export various fragments of the model before I found what exactly is wrong.
User avatar
Oleg
Site Admin
Posts: 14990
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: Exporting file almost doubles vertex count

Post by Oleg »

by the way, I have used your model recently to test the update of the exporter code in context of vertices/polygons count. A well-known 16Mb file limit was in a scope of my interest. After some time and tests I was able to run a 1.2mil vertices (1 mil triangles) model in game. (cloned detailed container part multiple times to get that high-poly model for tests).
Screenshot 2025-04-18 225520.png
Screenshot 2025-04-18 225452.jpg
...and this was about 70Mb per single .yft file:
Screenshot 2025-04-18 225612.jpg
Post Reply