Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

Flat Shaded Meshes don't decimate correctly #7

Closed
joshcamas opened this issue Mar 28, 2018 · 6 comments
Closed

Flat Shaded Meshes don't decimate correctly #7

joshcamas opened this issue Mar 28, 2018 · 6 comments
Assignees
Labels

Comments

@joshcamas
Copy link

Here's an example of what happens when decimation is applied to a flat shaded mesh exported from blender:
https://i.imgur.com/j0qlmcI.png

Here's another example. Flat shaded mesh decimated:
https://i.imgur.com/kTRDzMl.png

Smooth shaded mesh decimated:
https://i.imgur.com/v4I5DMo.png

@Whinarn
Copy link
Owner

Whinarn commented Mar 28, 2018

The problem here is that the Fast Quadric Mesh Simplification algorithm that I ported from C++ to C# doesn't support these kind of meshes.

The problem is most probably that you have vertices at the same position because you need different attributes for them and they aren't connected in any way. And this algorithm doesn't take that into consideration and holes are easily created. I am aware of this issue and am working on a solution in another project that I have based on the same algorithm that I plan to move to this project as well.

There is a way to prevent holes at the moment, through enabling the KeepBorders property of the DecimationAlgorithm. But it prevents the decimation algorithm to be effective in many cases.

Please see this issue for more information and updates:
Whinarn/UnityMeshSimplifier#2

I haven't had a lot of time over lately, but I will try to get this working as soon as I can. I will leave this issue open.

@Whinarn Whinarn self-assigned this Apr 1, 2018
@Whinarn Whinarn added the bug label Apr 1, 2018
@Whinarn
Copy link
Owner

Whinarn commented Apr 1, 2018

An update is that I have improved the algorithm in the UnityMeshSimplifier repository that aims to solve the same issue as you have experienced.

I will look into merging this into this repository as well.

@Whinarn
Copy link
Owner

Whinarn commented May 12, 2018

I have now implemented the new Smart Linking feature into this project, which should resolve this issue.

@joshcamas Could you please try out the latest version to see if your problem still persists https://github.com/Whinarn/MeshDecimator/tree/v0.2.0

Thanks!

@joshcamas
Copy link
Author

joshcamas commented May 18, 2018

Beautiful, it works perfectly!!!
https://i.imgur.com/BFamvET.png

Looks like there is some sort of issue still though, when there is a simplification (even one with a quality of 1) the shading gets wonky. I'll look into a bit more.

EDIT: It looks like flat shading is disabled when there is a simplification applied.

@Whinarn
Copy link
Owner

Whinarn commented May 18, 2018

Great to hear that it resolved your problem.

Could the shading issue be related to the normals? I can try to see if I have made a mistake with the normals somewhere. Thinking about it now (without having the code in front of me) it might be that the normals are not unit-length after simplification because of how the vertex attributes are blended.

@Whinarn
Copy link
Owner

Whinarn commented Jul 4, 2018

@joshcamas Are you still having problems with this?
Did you figure out the problem?

@Whinarn Whinarn closed this as completed Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants