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

Don't lock external edges during simplification #28

Conversation

SparkyPotato
Copy link

Objective

Only lock the edges internal to a mesh when simplifying groups, such that non-solid meshes will still have their edges simplified, leading to much better performance at lower LOD levels.

Solution

We generate a list of edge vertices at the beginning of the import, which define the border of the mesh as a whole. Then, when a group is being simplified, we calculate the border of the group, and remove any vertices that are in the mesh border.

The current implementation seriously affects the performance of the builder, since the entire vertex buffer has to be traversed to find the differences between the mesh border and group border. This can probably be optimized by generating a mini-vertex buffer for each group. The border computation code isn't particularly well-optimized either.

Copy link

github-actions bot commented Sep 6, 2024

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@JMS55
Copy link
Owner

JMS55 commented Oct 3, 2024

So it doesn't get lost:

This PR:
LOD: 0, meshlet count: 15616, meshlet occupancy counts: {128: 15615, 88: 1, }
LOD: 1, meshlet count: 8066, meshlet occupancy counts: {128: 6406, 127: 1114, 64: 352, 63: 156, 126: 29, 62: 7, 125: 1, 43: 1, }
LOD: 2, meshlet count: 4719, meshlet occupancy counts: {128: 2925, 64: 507, 63: 465, 127: 222, 32: 157, 31: 133, 62: 98, 96: 62, 95: 59, 126: 27, 30: 20, 94: 17, 61: 13, 29: 5, 125: 3, 93: 2, 66: 1, 28: 1, 85: 1, 46: 1, }
LOD: 3, meshlet count: 3128, meshlet occupancy counts: {128: 1958, 122: 19, 126: 18, 79: 17, 11: 16, 60: 15, 16: 15, 64: 14, 48: 14, 45: 14, 80: 14, 87: 14, 47: 13, 120: 13, 2: 13, 101: 13, 71: 13, 86: 13, 106: 13, 83: 12, 42: 12, 4: 12, 9: 12, 26: 12, 38: 12, 111: 12, 23: 12, 14: 12, 90: 11, 37: 11, 110: 11, 19: 11, 93: 11, 76: 11, 96: 11, 12: 11, 94: 11, 63: 11, 97: 11, 29: 11, 10: 11, 109: 11, 32: 11, 113: 11, 127: 11, 39: 10, 44: 10, 25: 10, 74: 10, 62: 10, 33: 10, 22: 10, 118: 10, 18: 10, 84: 10, 95: 10, 20: 10, 6: 10, 117: 9, 69: 9, 56: 9, 57: 9, 70: 9, 51: 9, 49: 9, 99: 9, 104: 9, 53: 9, 28: 9, 24: 9, 17: 9, 52: 9, 73: 9, 65: 9, 125: 8, 55: 8, 59: 8, 112: 8, 34: 8, 75: 8, 98: 8, 40: 8, 81: 8, 91: 8, 92: 8, 30: 8, 27: 8, 82: 7, 89: 7, 21: 7, 61: 7, 1: 7, 3: 7, 114: 7, 15: 7, 100: 7, 123: 7, 85: 7, 72: 7, 68: 7, 13: 7, 103: 6, 50: 6, 102: 6, 119: 6, 107: 6, 46: 6, 36: 6, 31: 6, 78: 6, 7: 6, 108: 6, 66: 6, 121: 6, 124: 6, 54: 5, 5: 5, 116: 5, 35: 5, 41: 5, 88: 4, 58: 4, 105: 4, 8: 4, 115: 4, 43: 4, 77: 3, 67: 2, }

Main:
LOD: 0, meshlet count: 15616, meshlet occupancy counts: {128: 15615, 88: 1, }
LOD: 1, meshlet count: 8066, meshlet occupancy counts: {128: 7550, 64: 515, 44: 1, }
LOD: 2, meshlet count: 4718, meshlet occupancy counts: {128: 3179, 64: 1066, 32: 321, 96: 143, 62: 5, 30: 2, 86: 1, 94: 1, }
LOD: 3, meshlet count: 2470, meshlet occupancy counts: {128: 1486, 32: 288, 64: 183, 96: 151, 112: 107, 16: 90, 80: 77, 48: 60, 46: 4, 30: 4, 62: 3, 74: 2, 110: 2, 44: 1, 14: 1, 98: 1, 126: 1, 28: 1, 20: 1, 114: 1, 58: 1, 100: 1, 106: 1, 84: 1, 56: 1, 116: 1, }
LOD: 4, meshlet count: 1284, meshlet occupancy counts: {128: 720, 16: 65, 64: 62, 112: 44, 32: 43, 80: 34, 48: 32, 40: 28, 8: 25, 104: 24, 56: 24, 88: 23, 96: 23, 72: 23, 24: 22, 120: 22, 116: 6, 22: 5, 12: 4, 30: 4, 18: 3, 126: 3, 94: 3, 70: 3, 102: 2, 14: 2, 110: 2, 98: 2, 20: 2, 90: 2, 10: 2, 76: 2, 38: 2, 108: 2, 82: 2, 6: 2, 26: 2, 50: 2, 86: 2, 46: 1, 122: 1, 84: 1, 92: 1, 2: 1, 78: 1, 28: 1, 42: 1, 68: 1, }
LOD: 5, meshlet count: 667, meshlet occupancy counts: {128: 364, 80: 16, 64: 15, 72: 11, 76: 10, 96: 9, 116: 9, 32: 8, 124: 8, 60: 8, 52: 8, 84: 8, 120: 8, 112: 8, 108: 7, 56: 7, 48: 7, 16: 7, 36: 6, 28: 6, 126: 6, 88: 6, 92: 6, 114: 6, 68: 6, 18: 5, 40: 5, 20: 5, 54: 5, 42: 4, 26: 4, 66: 4, 100: 4, 90: 4, 10: 4, 82: 4, 102: 3, 2: 3, 4: 3, 86: 3, 98: 3, 8: 3, 6: 3, 94: 3, 78: 3, 50: 3, 118: 3, 110: 2, 34: 2, 122: 2, 62: 2, 58: 2, 44: 2, 74: 2, 38: 2, 12: 2, 106: 2, 70: 2, 104: 1, 22: 1, 46: 1, 30: 1, }
LOD: 6, meshlet count: 392, meshlet occupancy counts: {128: 230, 82: 7, 58: 6, 118: 6, 18: 5, 56: 5, 80: 5, 60: 5, 14: 5, 70: 5, 102: 4, 110: 4, 36: 4, 104: 4, 46: 4, 84: 4, 106: 4, 68: 4, 2: 3, 64: 3, 40: 3, 126: 3, 44: 3, 74: 3, 12: 3, 96: 3, 122: 2, 32: 2, 4: 2, 72: 2, 42: 2, 48: 2, 86: 2, 16: 2, 52: 2, 66: 2, 98: 2, 24: 2, 20: 2, 90: 2, 10: 2, 8: 2, 120: 2, 6: 2, 30: 2, 78: 2, 114: 2, 116: 2, 50: 2, 34: 1, 76: 1, 26: 1, 124: 1, 28: 1, 22: 1, 54: 1, 88: 1, 92: 1, 38: 1, 112: 1, }
LOD: 7, meshlet count: 248, meshlet occupancy counts: {128: 159, 58: 7, 8: 5, 74: 4, 108: 4, 94: 4, 64: 3, 14: 3, 26: 3, 30: 3, 50: 3, 62: 3, 16: 3, 40: 2, 34: 2, 122: 2, 88: 2, 10: 2, 120: 2, 68: 2, 116: 2, 114: 2, 86: 2, 70: 2, 118: 2, 18: 1, 110: 1, 66: 1, 24: 1, 20: 1, 90: 1, 76: 1, 44: 1, 2: 1, 38: 1, 104: 1, 72: 1, 124: 1, 78: 1, 80: 1, 48: 1, 22: 1, 106: 1, 56: 1, 112: 1, }
LOD: 8, meshlet count: 172, meshlet occupancy counts: {128: 116, 8: 4, 24: 3, 74: 3, 42: 3, 66: 2, 126: 2, 54: 2, 10: 2, 4: 2, 94: 2, 30: 2, 50: 2, 116: 2, 22: 2, 86: 2, 60: 1, 46: 1, 52: 1, 102: 1, 98: 1, 34: 1, 58: 1, 88: 1, 84: 1, 90: 1, 76: 1, 108: 1, 38: 1, 36: 1, 104: 1, 26: 1, 80: 1, 48: 1, 62: 1, 68: 1, 70: 1, }
LOD: 9, meshlet count: 118, meshlet occupancy counts: {128: 81, 66: 2, 6: 2, 104: 2, 78: 2, 80: 2, 48: 2, 22: 2, 102: 1, 46: 1, 98: 1, 126: 1, 20: 1, 34: 1, 100: 1, 122: 1, 32: 1, 92: 1, 90: 1, 10: 1, 2: 1, 74: 1, 94: 1, 26: 1, 114: 1, 112: 1, 30: 1, 62: 1, 56: 1, 86: 1, 118: 1, }
LOD: 10, meshlet count: 72, meshlet occupancy counts: {128: 51, 46: 2, 40: 2, 18: 1, 108: 1, 66: 1, 98: 1, 6: 1, 24: 1, 94: 1, 34: 1, 80: 1, 112: 1, 48: 1, 58: 1, 22: 1, 62: 1, 116: 1, 86: 1, 10: 1, }
LOD: 11, meshlet count: 25, meshlet occupancy counts: {128: 18, 72: 2, 50: 1, 68: 1, 108: 1, 110: 1, 84: 1, }
LOD: 12, meshlet count: 4, meshlet occupancy counts: {128: 3, 50: 1, }

@JMS55
Copy link
Owner

JMS55 commented Oct 13, 2024

I ended up using zeux's slightly simpler code that just locks any vertex used by more than 1 group. It'll be part of an upcoming PR :).

@JMS55 JMS55 closed this Oct 13, 2024
@JMS55
Copy link
Owner

JMS55 commented Oct 13, 2024

bevyengine#15886

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

Successfully merging this pull request may close these issues.

2 participants