Understanding vertices in Procedural Mesh Component


I’m trying to understand how UProceduralMeshComponent works with this article.

I have found that I need to create the UProceduralMeshComponent in an actor to show it. My questions is about UProceduralMeshComponent’s vertices parameter:

@param	Vertices	Vertex buffer of all vertex positions to use for this mesh section.

Where are these vertex positions? From the actor or from the scene? I’m using a SpawnVolume (that inherits from ACharacter) to spawn the actor. I do it this way:

World->SpawnActor<AMyActor>(WhatToSpawn, SpawnLocation, SpawnRotation, SpawnParams);

Here, there is also another location (SpawnLocation) that I’m not sure if it is the same than @vertices parameter.

Vertex positions: These are, as the parameter name suggests, the positions of each vertex within the procedural mesh.

They are defined in local space, meaning that the vertex (0, 0, 0) would be exactly at the location of where that actor appears in the world.

A vertex of (10, 10, 0) would be 10 units forward and 10 units to the right from the first vertex (0, 0, 0) and so forward.

The X axis is the forward axis, and the Y axis is the right axis in Unreal.

(10, 0, 0) ------------------------------------- (10, 10, 0)




(0,0,0) ---------------------------------------- (0, 10, 0)

In order to get a mesh to appear, you must define at least a minimum of 3 vertices (i.e. enough to create a single triangle).

The parameter that is mentioned as Triangles (which I personally find to be a bad name as it is somewhat confusing), is what is commonly called as the Index Buffer.

A bit of googling and other resources can explain this better than I can, but basically, it is a more efficient way of specifying the way in which your mesh is to be created.

If you had three vertices, say (0, 0, 0), (100, 0, 0) and (0, 100, 0), in order to draw a triangle with these vertices your index buffer would have to be [0, 2, 1], where each value in the index buffer defines the order in which those vertices in the vertex buffer are joined on the GPU.

Why [0, 2, 1] and not [0, 1, 2] ?

This is because it is a common convention in computer graphics that vertices of a triangle are ordered in counter-clockwise direction.

This also helps later when calculating normals, where a face that is ordered counter-clockwise is considered to have the normals “facing outwards”.

Hope this helps!

1 Like

Thanks!!! This is a very good explanation.

1 Like

If it helped answer your question, kindly mark it as the accepted answer using that ‘tick’ symbol to the left of it.


Hey thanks for that detailed explanation! I understand the vertex ordering, but what I’m trying to do in my project is, using a spline to set the vertices and try and form a plane (fan triangle). Is there a way to arrange the Triangles array based on n number of spline points?
I’m trying to do this using Blueprints

That was a really detailed explanation. I had initially used the [0,1,2] approach and couldn’t see the mesh, because it was inverted. Trying the counterclockwise approach fixed the issue, but I had no idea why it was required to be that away. Thanks for providing the reasoning behind that.