The 64th Gamer

:MinecraftDiamondBlock: Pneumagination Chunk Mesh Plans

Alright so today gonna write down what I plan to do for Pneumagination brush meshes.

So, currently right now all brushes are shaded smoothly with no seperation of triangle groups, leading to a very noisy and unappealing look. The easiest solution is to just build each mesh face with seperate vertices like every other voxel game, but I actually want to retain it!

In Blender there is an option called “Auto Smooth” that dynamically splits the mesh and its normals based on the angle of connected vertices. If its above a certain angle, it splits. In this photo example the angle limit is set to 89, allowing sharp jagged edges to appear- while the angled faces stay smooth. There is one limitation with this implementaiton through, any vertex that needs to be split will split for all mesh faces that use it! In the photo you can see the top ramp does not smoothly transition into the horizontal and vertical sections. This is because the entire cube is being rendered and its other faces are splitting the vert.

Now, the first idea would be to remove unseen faces, but I don’t think generating occlusion trees for these meshes will be fast enough when editing, destroying, or placing brushes. Most likely we just have to deal with the performance hit of pushing all these triangles. Thankfully I already want the game to have a small render distance intentionally so this won’t be bad.

One way to solve this would be to group these auto smoothed groups together literally! Start with the first triangle, iterate recursively through all triangles with a shared vertex (Shared positionally that is. Right now duplicate vertices are in the final mesh but I may fix this in the initial generation if its faster) and put the connected triangles in a seperate list, then iterate with the next available triangle until you have 0 triangles left in the original list!

One benefit to this is that I could possibly keep track of the highest deviated angle- and if its 0 I can perform greedy meshing on the surface. Two problems- I don’t know if greedy meshing works with multiple disconnected planes joined by one vertex or how I could check if that’s happening, and also the fact that if any ramp connects into a large flat surface then it would disable the greedy meshing to ensure the smooth normals stay. Maybe if there was a way to check if neighboring faces connect to a ramp and then split just the other flat faces so both can be achieved, but that’s too much smart big brained stuff for me to comprehend right now.

Another issue is ensuring smooth transitions across chunk borders, but that’s like something I can solve waaay far out from now cause it wouldn’t be that drastic of a visual issue.

UPDATE: First pass of mesh normal smoothing done! All vertices with the same position are merged together. I originally did this really poorly and performance was horrible, but I swapped a compare check for a Dictionary and it went back to the normal generation speed. Also went ahead and added fog.

I’m not actually sure how I’m gonna pull off the next part without it being fairly slow. I assume I have to poll the face normal for every triangle and compare the angle? I don’t think that would work with the blocks post-merged because deviations in the face normal would change the angle comparison. That’d suck to do pre-merge though cause that means for every chunk split I’m re-testing the dictionary lookup for every outer vertex.

If I’m recalling things correctly though I think I can get a post-merge accurate face normal by finding the perpendicular angle to the vertices and then using the triangle indicies order to determine which of the two directions that is. That eats up the same amount of reads but then I have multiples less of verts to check.

Also since this step is essentially generating another set of normals I guess that means I don’t need to create that first set of normals at the start? I’m pretty sure I have to then average every face normal for every connecting vertex together but that might be more reliable than my current method of generating normals pointing from the center of mass. I’m glad I get to write my thoughts down like this it really solidifies my plans better! I think I’m gonna attempt this method next time.

Tags: