VOptimizer / VCore

VCore: A C++ library for voxel data loading, optimization, and real-time meshing, ideal for game development and 3D applications.
MIT License
0 stars 0 forks source link

Better Greedy meshing #1

Closed tostc closed 7 months ago

tostc commented 9 months ago

At the moment, the greedy mesher only meshes its current chunk, which is assigned to the thread. This behaviour can be observed here. To fix this problem, the output of the threads should be combined in an extra stage and then the mesh should be generated.

tostc commented 9 months ago

The new mesher is finished.

ZsoltHevesi commented 9 months ago

The new greedy mesher definitely reduces vertex count more than the "chunky greedy" setting, however it is still not perfect. Here are the comparisons between the ones VOptimizer uses:

Original coloured: Screenshot (337)

Greedy: Screenshot (338)

Chunked Greedy: Screenshot (339)

And this is how it would look when using the correct algorithm: (got this one using this Blender addon: https://github.com/AstrorEnales/blender_magicavoxel) Screenshot (340)

tostc commented 9 months ago

I notice an issue in my implementation yesterday, maybe this would result in a better result. At the moment I'm adding the option to the new greedy algorithm to generate a texture instead of just a colorpalette. This would result in less vertices and faces, but a bigger texture. Similar to your blender addon.

I've didn't look at the source of the addon, only at the readme but this addon and my library using the same source for the greedy algorithm. But maybe not the same implementation. I make use of multithreading, which generates this chunk like pattern of 16x16x16 cubes as seen in the greedy chunk algorithm.

ZsoltHevesi commented 9 months ago

I believe the addon does have a texture option, but I don't use it, I actually prefer your solution to simply use the default diffuse colours on parts that don't have materials, as it's cheaper to render but looks the exact same.

tostc commented 9 months ago

I've released a new version, where I fixed the bug I mentioned. Maybe the result is now better for your mesh.