Coding Adventure: Marching Cubes

Sebastian Lague · 1.1M views · 2019 · 6:18

Open on YouTube

Computer graphics & renderingGame programming & enginesCreative coding & generative artdemo

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about voxel meshes, 3D surface generation, and implementing marching cubes in Unity or Python.

Recommended by 4 people across 4 different months, 2020 to 2022.

What it is

Sebastian Lague's short Coding Adventure video works through the marching cubes algorithm, then uses it to build a map editor, procedural terrain, and an endless underwater world. It includes a visual walkthrough of the lookup-table approach and links to the project files and papers.

What people said

Recommends KdotJPG · 2020-02 · Stack Overflow · on “Is there a built in way of efficiently finding if a vector is in a vector array and if so what # variable it is”

If you're using a triangulation lookup table based implementation of marching cubes, you could store a normal vector alongside the face in the same table entry. A video by Sebastian Lague mentions using such a table. I'm not exactly sure where he downloaded it from, but he includes it in his repo which is MIT licensed. Video [this video] , Table [LINK] (EDIT: The order of a triangle's vertices alone may be sufficient to define its direction, and you may not need an explicit normal vector) Also heads up: Old Perlin noise tends to be visibly grid aligned. Most times I see it used, appear to be because a library provided it or because it was mentioned in a tutorial, and not because it was actually t

Recommends CosmicGiant · 2020-03 · Stack Overflow · on “Alternatives for updating mesh collider in runtime?”

A voxel-based solution is the answer here, clearly. As for how to implement one, I can't give you details because, although I know what the answer is in general, I have never implemented a Voxel engine myself, and neither have I used any existing one. So I can only point you in the right direction. Basically, instead of trying to create the mesh from arbitrary points, you create it from fixed, finite, easily-optimizable ones. It's how Minecraft, and even more complex games, do it. Sebastian Lague has a video covering some of the core stuff related to the mesh-generation in this video [this video] .

Recommends TEEBQNE · 2021-04 · Stack Overflow · on “Building/placing objects system in unity”

But as I mentioned, there are a lot of better resources now that help ease the information in a more digestible way. Instead of reading papers you can watch videos [this video] . I would just start watching videos about the subject and the YouTube algorithm should start recommending more videos to you.

Recommends Cadeyrn · 2022-07 · Stack Overflow · on “How to establish a 3D model with a 3D array with grayscale values? [python]”

You can use the marching cubes algorithm ( here [this video] is a good video explaining it), and the python stl library [LINK] to create an usable file.

Cites Soupman59 · 2020-02 · Stack Overflow · on “Mesh not changing programily”

So I am trying to create my own version of Sebastian Lauge's marching cubes coding adventures ( [this video] ) and I have a script that generates perlin noise into terrain on the Y-axis ant Im trying to make it so it creates perlin noise for the x, y, and z axis and compile vertices from that perlin noise into a mesh. Rightnow I'm in the process of adding the code to decides which points should be put into the mesh The problem is that I have to change the variable y in lines 49 - 56 to the variable ypn (declared on line 45) and leave the y variables out of that area alone the problem is that if i change one of those y variables (don't know which one) it will make the mesh flat and that's not what

Cites Codeman · 2022-10 · Stack Overflow · on “Uniformly sampling points in a cube using a coordinate system [C#, Unity]”

I have a cube with six vertices of form (x, y, z) , in a 3D coordinate system. All information about cube is available, including vertices, edge lengths, etc. I would like an efficient way to uniformly return n ^ 3 points, with n points on each edge, something like the coordinate system itself. An image is attached (ignore the colouring) (source: Sebastian Lague's video on marching cubes [this video] ): [LINK] I've more or less been able to implement this in Python, and I'd like a C# version. An example of what I want: I've used a unit cube at the origin as an example, what I'm after is pseudocode or logic that works for any cube at any coordinates. More information: I'd like to have code that wo