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

Add example 42 : BunnyLOD #2155

Merged
merged 1 commit into from
May 30, 2020
Merged

Add example 42 : BunnyLOD #2155

merged 1 commit into from
May 30, 2020

Conversation

cloudwu
Copy link
Contributor

@cloudwu cloudwu commented May 30, 2020

I reimplement https://github.com/dougbinks/BunnyLOD in bgfx today.

There are still some issues:

  1. I use the shaders vs_picking_shaded and fs_picking_shaded of 30-picking.
  2. Init is too slow ( 8 seconds in my computer) , because the algorithm is O(n^2) , and bunny.bin have more than 100k vertices. A simpler mesh would be much faster.
  3. This LOD algotithm need removing the vertices with the same position. The exist bunny.bin have many vertices with the same posiotions (different normals). I wrote functions findDuplicateVertices and mergeVertices to merge these vertices. It's O(n^2) , too. But I think it can be done offline.

image

@cloudwu cloudwu requested a review from bkaradzic as a code owner May 30, 2020 17:09
@cloudwu cloudwu mentioned this pull request May 30, 2020
@cloudwu cloudwu changed the title Add examples 42 : BunnyLOD Add example 42 : BunnyLOD May 30, 2020
@bkaradzic bkaradzic merged commit be95d12 into bkaradzic:master May 30, 2020
@bkaradzic
Copy link
Owner

One thing you could do is cache result like 40-svt does. It's slow only first time, and on second load it just uses cached results.

There is issue with vertex count when lowering LOD level:
bunny-lod-bug

@bkaradzic
Copy link
Owner

This LOD algotithm need removing the vertices with the same position. The exist bunny.bin have many vertices with the same posiotions (different normals). I wrote functions findDuplicateVertices and mergeVertices to merge these vertices. It's O(n^2) , too. But I think it can be done offline.

There is utility function bgfx::weldVertices that should output only unique vertices.

https://bkaradzic.github.io/bgfx/bgfx.html#_CPPv4N4bgfx12weldVerticesEP8uint16_tRK12VertexLayoutPKv8uint16_tf

@cloudwu
Copy link
Contributor Author

cloudwu commented May 30, 2020

I'll improve this example tomorrow.

There is issue with vertex count when lowering LOD level:

If there are holes in the mesh, the hole would enlarge when the mesh collapse to lower version. The mesh bunny.bin is not closed at the bottom. I think it's a defect of this LOD algorithm.

@bkaradzic
Copy link
Owner

is not closed at the bottom. I think it's a defect of this LOD algorithm.

Makes sense. Switched to bunny_patched and it works now.

@cloudwu
Copy link
Contributor Author

cloudwu commented May 31, 2020

I want to use bgfx::weldVertices today, but I found it use uint16_t for index. Is there any reason for this limit ?

bunny.bin has about 100K (>64K) vertices.

@bkaradzic
Copy link
Owner

None. I'll update API to be 32-bit.

@bkaradzic
Copy link
Owner

Updated: 977188e

@cloudwu
Copy link
Contributor Author

cloudwu commented May 31, 2020

Done #2156

rozgo pushed a commit to VertexStudio/bgfx that referenced this pull request Aug 14, 2020
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