Whinarn / UnityMeshSimplifier

Mesh simplification for Unity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mesh with vertex colors issue

Nostromo90 opened this issue · comments

Hi,

i have another request (it's more enhancement than bug).

To maximize perfromances in VR I use special shader and vertex color of a mesh.
but when decimation is performed on a mesh with submeshes and several colors then you remove some vertices (maybe ducplicate) but without verifying the color of vertice

Here is the result.

decimated
notdecimated

Could you do something? without impacting too much the performances of decimation?

TIA.

This might actually be a bug however. There should be more than one vertex sharing the same position around those yellow things, right? Because in that scenario where the vertices are sharing the same position but are not actually connected through triangles, then they shouldn't ever merge. With the smart linking feature they would be treated as one vertex, but the attributes should remain unique for both of them. But seeing this, it looks like vertices with the yellow color are being merged with vertices with the red color. Or that the vertex attributes are incorrectly used during the vertex merge process.

I will try to look into it from my side.
Are the red and yellow parts different sub-meshes?
Are they connected through triangles somewhere? Or are they separate islands so to speak?

Hi,

Yes it's 2 submeshes (1 red and 1 yellow)
For the other questions I don't know, so I provide you the mesh it will be easier (this one is public)

quad.zip

I think that I just figured out the problem just after posting this. I deal with UV-seams and UV-foldovers (when the UVs are the same on both sides), but in theory I should deal with attributes like color as well. Let me think about how to solve this. I will get back to you tomorrow, or next week once I get more time.

And thanks for the sample!

I looked into the mesh that you provided and I can see that the yellow and red parts are actually connected. See my screenshot below where I zoomed in and you can also clearly see the blending from the yellow/orange to red. I'm not sure that this can be easily solved actually. Especially not in a way that won't drain performance. But if you have any ideas, I would be open to them.

The problem I mentioned above is still real however and I will work on resolving that.

image

Hi,

First, I tested your new code enhanced. Performances are amazing Test performed
CAD file with 700 Meshes (about 30M of tris)
- Former version: 30 minutes to read files, Parse and decimate 1 time for collider
- New version: 4 minutes ot read files, Parse and decimate 2 times (MeshFilter and Meshcollider)
So congratulation for this code enhancement.

ABout my problem, I will have to check as it's really 2 SubMesh which are not shared same vertices (at least in the source)

As you can see in the screen of CAD source. Vertices and Triangles for Red and Yellow are not the same.
So I will look deeper in my code to understand why it seems to be merged (Unity enhancement of meshes? or my fault)

Red part triangles and vertices
redpart

Yellow part triangles and vertices
yellowpart

Great to see such huge improvements for you!

Could you verify the import settings in Unity for this model? Could it be "Optimize Mesh" that does this?

Edit: I just checked in Unity myself. The import settings are not available since it's only one mesh. But I could confirm that there are only two sub-meshes for the sample that you sent above, and those are two different. And the yellow part is on the top. Those blended things (are they lights or something?) are orange, which could very well be the third one from the top (red 1, green 0.501961). And I am guessing that that one shares vertices with the red part, and that is the problem. What do you think?

Hi

Yes I Will check it deeper but you are probably right...
So in this case it will be difficult to fix it...

If I confirm on my side I will close the ticket

Hi I confirm that same triangles contains 2 colors.
Thanks for support