Procedural geometry =================== There are many ways to procedurally generate geometry in Godot. In this tutorial series we will explore a few of them. Each technique has its own benefits and drawbacks, so it is best to understand each one and how it can be useful in a given situation. .. toctree:: :maxdepth: 1 :name: toc-procedural_geometry arraymesh meshdatatool surfacetool immediategeometry What is geometry? ----------------- Geometry is a fancy way of saying shape. In computer graphics, geometry is typically represented by an array of positions called "vertices". In Godot, geometry is represented by Meshes. What is a Mesh? --------------- Many things in Godot have mesh in their name: the `Mesh`, the `MeshInstance`, and the `MultiMeshInstance`. While they are all related, they have slightly different uses. Meshes and ArrayMeshes are resources that are drawn using a MeshInstance node. Resources like Meshes and ArrayMeshes cannot be added to the scene directly. A MeshInstance represents one instance of a mesh in your scene. You can reuse a single mesh in multiple MeshInstances to draw it in different parts of your scene with different materials or transformations (scale, rotation, position etc.). If you are going to draw the same object many times, it can be helpful to use a MultiMesh with a MultiMeshInstance. MultiMeshInstances draw meshes thousands of times very cheaply by taking advantage of hardware instancing. The drawback with using a MultiMeshInstance is that each of your mesh's surfaces are limited to one material for all instances. It uses an instance array to store different colors and transformations for each instance, but all the instances of each surface use the same material. What a Mesh is -------------- A Mesh is composed of one or more surfaces. A surface is an array composed of multiple sub-arrays containing vertices, normals, UVs, etc. Normally the process of constructing surfaces and meshes is hidden from the user in the `VisualServer`, but with ArrayMeshes, the user can construct a Mesh manually by passing in an array containing the surface information. Surfaces ^^^^^^^^ Each surface has its own material. Alternatively, you can override the material for all surfaces in the Mesh when you use a MeshInstance using the `material_override` property. Surface array ^^^^^^^^^^^^^ The surface array is an array of length `ArrayMesh.ARRAY_MAX`. Each position in the array is filled with a sub-array containing per-vertex information. For example, the array located at `ArrayMesh.ARRAY_NORMAL` is a `PoolVector3Array` of vertex normals. See `Mesh.ArrayType