Marching Cubes Animation | Algorithms Visualized

  Рет қаралды 73,139

Algorithms Visualized

Algorithms Visualized

Күн бұрын

Пікірлер: 28
@Jico762
@Jico762 7 жыл бұрын
Thank you for this!! I've been having a hard time visualizing the formulas in my head and this has been super helpful!
@steve64959
@steve64959 6 жыл бұрын
This has been a great help for me! Thanks for creating this video!
@qwertyuuytrewq825
@qwertyuuytrewq825 6 жыл бұрын
thk! Understood principle of work of marching cubes very fast
@huanwang368
@huanwang368 3 жыл бұрын
Thank you! This is very useful!
@zhangxaochen
@zhangxaochen 6 жыл бұрын
excellent animation~ THX!!
@izzahtahir796
@izzahtahir796 3 жыл бұрын
I want to implement in matlab how to do that
@FlashBreakerOfficial
@FlashBreakerOfficial 4 жыл бұрын
thx! helps me a lot :D
@fallenhoenix1255
@fallenhoenix1255 6 жыл бұрын
Shouldn't the formula be t = d1 / (d2 - d1)?
@algorithmsvisualized9025
@algorithmsvisualized9025 6 жыл бұрын
It has been a while. The sign of the samples is guaranteed to be different, if you subtracted that way then the result would be negative. Checking with a pen and paper it seemed correct as is.
@fallenhoenix1255
@fallenhoenix1255 6 жыл бұрын
@@algorithmsvisualized9025 ok. Thanks!
@foxyr4bbit
@foxyr4bbit 5 жыл бұрын
hi, one thing i don't quite understand is how do you get the vertex coordinates?
@algorithmsvisualized9025
@algorithmsvisualized9025 5 жыл бұрын
You have a lookup table for each of the 12 edges. The table could store indices of the 2 corners and then you choose a point between those 2 corners (or middle point in the simplest case). If you add that to the min corner coordinate of current cube, you'll have the vertex coordinate. Thats one way to implement it.
@theshuman100
@theshuman100 6 жыл бұрын
Hhngh look at em cubes go
@rotcivgenerico1089
@rotcivgenerico1089 4 жыл бұрын
I didnt understood completely the vertex interpolation part i manager to make it work setting t = 0.5 in all cases, but how can i calculate the t value correctly? its said that "if we have a continuous field of values..." what do you mean by a "continuous field of values"?
@algorithmsvisualized9025
@algorithmsvisualized9025 4 жыл бұрын
With marching cubes you determine the signs at the cube corners. Two corners that are on the same cube face are connected with an edge, if the signs of these corners are different it means that the surface you're trying to create must intersect at some point on that edge. The t value would be the point where the surface intersects the edge. You could use middle point of that edge where t=0.5, but most likely the intersection point wasn't exactly in the middle. The formula in video is just an approximation I've seen used a lot, definitely won't work with any data. For example imagine running marching cubes on minecraft data, a block either exists or doesn't exist, there is no value in between. 0.5 would be the best you can do knowing that on one side there exists a block and on other side there is nothing. In the video I used signed distance field of a sphere, the value changes smoothly - there is no sudden step. In that case we can make a better guess than 0.5 based on how much the value changed. The truly correct way for a sphere would be to do a raycast (ray sphere intersection) along the edge, but in practice this might be too slow. Most likely you won't use a sphere so you'd use some kind of approximation that works for your data. For example a brute force way would be to just walk along the edge with some step size until the field changes value, to do that you must have a continuous function to sample the value at every point. The method used in video is way less accurate but its fast to compute and looks better than just using 0.5 (for signed distance fields). Hope this helps
@segmentation_fault4569
@segmentation_fault4569 3 жыл бұрын
Hello. How can I use your implementation of the algorithm to denote voxels? In my case, there are two kinds of voxels, empty and solid. Voxels are in a bounded cube. Your example produces a sphere, but I am unable to modify it to create a solid voxel mesh. Please tell me how this can be implemented. Thank you in advance.
@algorithmsvisualized9025
@algorithmsvisualized9025 3 жыл бұрын
Hello In the implementation there is SampleValue function. It takes in a coordinate and outputs a value, you can return 1.0 for solid and -1.0 for empty voxel. It would also be optimal to remove the interpolation by changing line 77 to "Vector3 vertPosInterpolated = (vert1+vert2)/2.0f;" and deleting line 66-76. Hope this helps.
@segmentation_fault4569
@segmentation_fault4569 3 жыл бұрын
​@@algorithmsvisualized9025​, Thanks for your reply. I tested this and it didn't get any results. Before that, when calculating the configuration of the cube, I set a check that the side point is less than the minimum chunk vector and that this point is not more than the maximum vector. The grid was built around the chunk.
@algorithmsvisualized9025
@algorithmsvisualized9025 3 жыл бұрын
@@segmentation_fault4569 Make sure the volume contains a sign change. The alorithm only creates the isosurface where value is 0. So in case of a cube the volume you march has to be bigger than that cube.
@segmentation_fault4569
@segmentation_fault4569 3 жыл бұрын
​@@algorithmsvisualized9025 Hi. Thanks for your help! I was able to resolve this issue. Getting the configuration of the cube by its corners, I added a check to see if the voxel is empty in the angle coordinates, and also checked to see if the corner was beyond the chunk height. Everything worked as it should. If I have problems again, with your permission, I will write about it here so that other people can see the solution with my example.
@repogamesstudio2366
@repogamesstudio2366 7 жыл бұрын
looks awesome ;)
@mbdesign8118
@mbdesign8118 6 жыл бұрын
Good
@teroblepuns
@teroblepuns 4 жыл бұрын
Is there a way to rotate the grid? Imagine making a spherical planet which you would want to be able to terraform as it rotates around its central axis. Yes, you could keep the planet stationary and just rotate the skybox and clouds and perhaps other planets around it, but I'm looking for a solution where someone could move the entire voxel planet while rotating it around all axis as someone is simultaneously terraforming the voxel terrain at the same time.
@brock7682
@brock7682 3 жыл бұрын
i'm sad no one has a answer...
@M4gidev
@M4gidev Жыл бұрын
It is not possible to rotate a grid without loss of data or a huge cost of performance and memory, but it is possible to rotate the grid reading using matrix4x4 or quaternions, you apply the rotation in the coordinates to be read and interpolate the voxel values between the final coordinate, I recommend studying quarternions and signed distance field (SDF).
@austineldredge8003
@austineldredge8003 11 ай бұрын
this answer is sorta specific to UE5, but could be applied anywhere. By creating a producedural mesh as a component seperate from the rest of the "game world" in UE5, you can create the grid so that the vertices are all relative to a parent component, in this case an invisible scene actor in the middle, rotate the parent component, you rotate all vertices in the mesh. Unreal Engine already allows this funcitonality in other mesh's as long as you're creating the mesh and not re-calculating it every scene or movement, you could theoretically do this, The cost of modify these meshes itself is expensive though, so molding a world would tie its cost directly to the resolution of the "planet" where resolution is the amount of vertices in a grid. hopefully that makes sense.
@Kyoz
@Kyoz 2 ай бұрын
🤍
@pajeetsingh
@pajeetsingh 4 жыл бұрын
Bruh you can speak, I won't judge you by your non-English speaking accent, Promise.
How Computers Draw Weird Shapes (Marching Squares)
28:00
Reducible
Рет қаралды 412 М.
Coding Marching Squares
26:28
The Coding Train
Рет қаралды 184 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
I Made a 32-bit Computer Inside Terraria
15:26
From Scratch
Рет қаралды 4,1 МЛН
Coding Adventure: Ray Marching
5:06
Sebastian Lague
Рет қаралды 1,1 МЛН
Voxel Game Mesh Optimizations
7:30
Hopson
Рет қаралды 179 М.
Sticky cubes, an alternative to marching cubes
10:37
Jakob Furbo
Рет қаралды 48 М.
My Adventure with 3D Perlin Noise
4:28
Nova840
Рет қаралды 480 М.
10 FORBIDDEN Sorting Algorithms
9:41
Ardens
Рет қаралды 943 М.
Procedural 3D Engine. Ray Marching OpenGL Tutorial
15:31
Coder Space
Рет қаралды 37 М.
Mesh from Math - The basics of Marching Cubes
6:52
Deadlock
Рет қаралды 19 М.
How Big Budget AAA Games Render Clouds
10:45
SimonDev
Рет қаралды 281 М.
10 weird algorithms
9:06
Fireship
Рет қаралды 1,3 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН