MESH GENERATION in Unity - Basics

Brackeys · 503K views · 2018 · 11:10

Open on YouTube

Game programming & enginesComputer graphics & renderingIndie game developmenttutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about procedural mesh generation in Unity, such as triangle winding, vertex setup and building voxel-style chunks.

Recommended by 3 people across 3 different months, 2020 to 2024.

What it is

A short Brackeys tutorial on generating meshes from code in Unity. It covers building vertex and triangle arrays, assigning them to a Mesh, and getting a simple custom object to render. Presented in Brackeys' usual screen-recorded, step-by-step style.

What people said

Recommends Apoqlite · 2020-11 · Stack Overflow · on “How do I turn a flattened 3d array of vertices to a array of triangles?”

Hello I'm using Unity and C# along with the Mesh renderer and filter to simulate a chunk of 16*16*256 (a Minecraft chunk). Following the following video [this video] as a guide. I have 3 constants : Globals.CHUNK_X (shortened to W) Globals.CHUNK_Y (H) Globals.CHUNK_Z (D) I also have a function Globals.c3to1(x, y, z) which converts a 3d index to a 1d index in a (W+1)*(H+1)*(D+1) array of vertices by returning the following (H+1) * (W+1) * z + (W+1) * y + x . I arranged my vertices in a 1d array of dimensions (W+1)*(H+1)*(D+1) called vertices such that vertices[c3to1(x, y, z)] = (x, y, z) . Now that I have my vertices how do I go along getting all the triangles into an array. I have created a for l

Recommends enots227 · 2021-01 · Stack Overflow · on “How to get vertex colors working in Unity project?”

I figured it out with the help of this YT tutorial [this video] . I was rendering the triangles on the opposite side of where my camera was directed at. Merely changed the order of the triangle indexes. triangles[tOffset] = vOffset; triangles[tOffset + 1] = vOffset + 2; triangles[tOffset + 2] = vOffset + 3; triangles[tOffset + 3] = vOffset + 2; triangles[tOffset + 4] = vOffset + 1; triangles[tOffset + 5] = vOffset + 3;

Recommends TSDrake · 2024-08 · Stack Overflow · on “How to make the radius of a 3D pipe bigger without changing its thickness in unity”

To do objects like this you may need to do a mesh generation script with some parameters as: Height (float) Radius (float) Thick (float) HeightCuts (int) LoopCuts (int) For the code and understand it better i sugest to view as always some Brackeys video: [this video]