Blackvoxel > General Discussion
Smooth Meshing (I know; something noone's asking for :) )
(1/1)
d3x0r:
I've been toying with smooth meshing for a while, determined to not have to use 'marching cubes'; that surly there's a simpler way. It's maybe not a 'better' way in all aspects...
https://gist.github.com/d3x0r/5633f0548f4d7b283f8bab19e022acad (pretty pictures included)
(How much TL;DR to include...)
tetrahedra only have 2 mesh modes - 1 point in/out and an edge out which generates a quad that's not constrained flat.
The example code is JS; and it looks like a lot; the plane mesher (that calculates each shared point only once) is actually simple (perhaps it's because I've been staring at it for dayz). That is, the first version was long-form expanded with if's; and series of statements; I consolidated those into lookup tables, and 'simplified' the overall required code, at the cost of legibility perhaps? (Like I never really did understand your face mating tables :) )
This forms a mesh around the points as a center (instead of sort of in-a corner of the cube), which offsets it by (0.5,0.5,0.5); but for things like trees, and other geography would think smoothing would work well, using world-space coodrinates for texture uv-coordinates; was also playing with the ability to 'inflate/deflate' the mesh and realized that meshing water deflated and land inflated would give a very nice transition.
Still requires a pass to stitch sectors together; otherwise data has to be duplicated; can easily do default 'outside' 'inside' by faking 1 render point outside... hmm actually that's just on the stitch line; I should add the stitch pass as another option...
There is certainly a lot of space for square meshes!
Peace and good health to you!
d3x0r:
Updated a bit; added 'Show Grid' option, which uses a shader to draw rectilinear grid lines :)
Actually, marching cubes, with show grid is actually very rectangular...
https://d3x0r.github.io/MarchingTetrahedra/
Enigma:
Hi, D3x0R, glad to see you :)
Thanks for sharing your tought about tetraedron. We'll read it.
Like triangle is more a primitive than square, Tetraedron is more a primitive than cube.
Cube is easier to handle for player. Tetraedon permits more details with less sharp edges.
Be carefull about Coronavirus as it is spreading massively worldwide now.
The Blackvoxel Team
d3x0r:
https://d3x0r.github.io/IsoSurface-MultiTexture/
This needs almost a whole user manual :)
Some important things I should point out - Show Edges - draws the wireframe model; this is sometimes generated as a quad of line segments - so it misses a triangle across; it was assumed that the intersection through 4 edges was flat; it is not. But! Show Edges allows to show where water is transparent(for instance)
( This needs Multi-pass to render solid, and then transparent/liquid phases; but it's just a simple demo )
The inflation slider, when in a normalized position, allows inflating and deflating the land; which for a landscape game could be applied for solid and liquid phases. (A different game entirely)
But; 1:10, 1:1, 10:1 scaling options are fixed cube position things... making all the computations digital instead of analog... Minimize/Maximize even moreso... My first pass at smooth-ish rendering is sort of like maximized mode - which pushes out edges, and causes some dimpelling... Minimize is a totally opposite effect, making inner corners inset instead of out-set...
Stylistically I like the 1:1 , with edges.
I was going to do a custom index-blackvoxel.html which reduces the terrain texture (except where there is specular light reflection, and a black surface with a grid. )
I did have to scale/bias the grid because on maximized/minimized initially, the planes at 0, 1, 2, 3, etc, are all exactly on one of the axis lines so the whole faces lit up with the grid-glow; I believe this is an improper style... but depending on where you scaled (well the previous message has the grid render - on some of the things you can see the purple sort of over-glow - like on the back of 'terrain' input data with 'outside' enabled (which closes in the bottom, and generates just random data... (random is worst case for input; the functions make nice smooth curves, the scaling 1:1 sort of options normalize randomness... (but really sort of make it a flat plane).
I think instead I can measure the face normal and de-emphasize the axis that the plane is aligned on... (scale by 1-normal )
Hope you all are well!
d3x0r:
Started a 'smarter' / better ... Dual Marching Tetrahedra. Pass 1 - compute Tetrahedra, which each face results in a point. Use those points on the faces to make edges of new faces. It smooths out some of the very pointed artfacting and makes a much smoother result.
Unfortunatly, the multi-texturing becomes a merge of 3-5 (depending on how it's looked at) x 3 vectors each , so I fell back to just downloading the 'element' or 'voxelType' information to the shader... I took the 3d volume and tiled slices on a texture so I can look up in x/y/z of the point what the type is; but this makes very sharp edges between types... there's basically no merging (well, that, and I sort of over-multiply points that should otherwise not count... it's still sort of a work-in progress to get the textures in 'Show Grid' mode to work well).
https://d3x0r.github.io/DualMarchingTetrahedra/
Also, there's a lot of points on the grid that generate overly small triangles (I could loosen my tolerances and it would probably work better); but I recently added the 'show normals' to show the 'reason' that there are flips in the quads generated....
Navigation
[0] Message Index
Go to full version