mino-git / rtcw-wet-blender-model-tools

Support for MD3, MDC, MDS, MDM/MDX and TAG file formats for the 3D modeling software Blender.
GNU General Public License v2.0
34 stars 3 forks source link

Wrong Normals on Exported Models #5

Open houthakker888 opened 4 years ago

houthakker888 commented 4 years ago

Hi again, back with more of a question this time: how can I prevent vertices from being duplicated when exporting? If vert count is high enough, even with no islands, verts on seams will be duplicated resulting in incorrect normals.

Is there a good way to fix this? Or is there any way to edit verts/normals directly on the exported files?

houthakker888 commented 4 years ago

After experimenting (and reading the codes), I think it wasn't a problem with the added verts after all. It appears that the addon re-generates normals based on orientation of verts from weighted bone. Adding verts to a mesh changes weights a bit, so borders of vertex groups will have wrong normals. Re-painting weight messes it up completely.

I haven't a clue how this could be fixed tho :(

mino-git commented 4 years ago

Hi,

EDIT and yeah, i once had custom normals support in the addon. But on skeletal models i could not figure out how to map them to the formats math, since again, i could not figure out how they did the normals algo wise. It was one of those remaining secrets of the formats, so i just came up with an approximated algo.

houthakker888 commented 4 years ago

Here: normals normals2

I'd guess that the addon calculates normals from only 1 bone at a time, so when a vertex has multiple weights, this happens. Would it be possible to do all and average?

EDIT actually I think re-importing to Blender might be automatically fixing the normals. They look fine in Blender.

houthakker888 commented 4 years ago

normals This one is clearer since the earlier one was re-painted and smoothed. Black patches on vertex group borders.

houthakker888 commented 4 years ago

Hi again, I've found a workaround for now: For some reason, if only 1 vertex has multiple weights, the normals will be fine. If 3 or more vertices in a row have multiple weights, the ones in the middle will have wrong normals. I redid the weights and made sure to have 1 vertex borders, so it works, although the model is not nearly as good as a full repaint would make it.

Hopefully this info will help identify and solve the problem.

EDIT nvm it looked good in Q3MT but not in game :(

mino-git commented 4 years ago

Hi, i'll take a look as soon as possible.

As a sidenote: the formats do not support more than 3 weights per vertex, just so you know. The addon generates a warning in the system console if it finds a vertex which is influenced by more than 3 bones AKA has more than 3 weights.

houthakker888 commented 4 years ago

Thanks, I didn't know that! More than 3 means exactly 3 is good right?

I tried limiting both weight levels and weights per vertex to 2 though, still no good :(

mino-git commented 4 years ago

"More than 3 means exactly 3 is good right?"

3 is good.

mino-git commented 2 months ago

Hi, could you solve this issue by making sure you do not use more than 3 weights per vertex? The 'not more than 3 weights per vertex' is actually a format limitation as far as i remember. It might be somewhere in rtcw source code.