# Triangle vertex order changes face normal?

**URL:** <https://forums.unrealengine.com/t/triangle-vertex-order-changes-face-normal/360789>\
**Category:** C++\
**Tags:** vertices, unreal-engine, procedural-mesh, CPP, question\
**Created:** [June 14, 2016, 7:32pm UTC](https://forums.unrealengine.com/t/triangle-vertex-order-changes-face-normal/360789 "2016-06-14T19:32:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jayae](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jayae](https://forums.unrealengine.com/u/Jayae)\
**Post date:** [June 14, 2016, 7:32pm UTC](https://forums.unrealengine.com/t/triangle-vertex-order-changes-face-normal/360789/1 "2016-06-14T19:32:04Z")

</div>

Hi!

I’m trying to use this article to learn a bit about procedural meshes:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

When I add in a 4th vertex so that I can make a simple square, no matter the normal I assign to it, it seems the normal of the new triangle seems to change depending on the sequence that the vertices are connected?

```
TArray<FVector> vertices;
	vertices.Add(FVector(0, 0, 0));
	vertices.Add(FVector(0, 100, 0));
	vertices.Add(FVector(0, 0, 100));

	vertices.Add(FVector(0, 100, 100));

	TArray<int32> Triangles;
	Triangles.Add(0);
	Triangles.Add(1);
	Triangles.Add(2);    
	
	Triangles.Add(1);
	Triangles.Add(2);
	Triangles.Add(3);
	    	
	//Triangles.Add(3);
	//Triangles.Add(2);
	//Triangles.Add(1);
	
	TArray<FVector> normals;
	normals.Add(FVector(1, 0, 0));
	normals.Add(FVector(1, 0, 0));
	normals.Add(FVector(1, 0, 0));

	normals.Add(FVector(1, 0, 0));

```

To me it seemed logical that my new triangle needed to be made of the **Triangles** indices: 1,2, then 3. This ended up making a triangle like this picture (spawned two copies of the Actor to show the different triangle normal):

 ![94638-ue4tri1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/4/3/343b6a57a2b77b6fa63c564a1ff75567e343bd44.png)

But if I change the order of the **Triangles** indices to be 3,2, then 1 (as in the commented out code) then I get a more correct looking face:

 ![94640-ue4tri2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/c/8bcd362e9f53ceb8590772ed15b872f9f4f78ed7.png)

Why is it that the order of adding the indices matters? And how do we work out which way we want in more complex geometry?

---

<div class="post-metadata">

**Author:** ![Jayae](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jayae](https://forums.unrealengine.com/u/Jayae)\
**Post date:** [June 15, 2016, 3:52pm UTC](https://forums.unrealengine.com/t/triangle-vertex-order-changes-face-normal/360789/2 "2016-06-15T15:52:53Z")

</div>

Looking at this 24hrs later, it looks like it’s to do with the winding order. I learnt something today! I suppose for these simple shapes I should just focus on getting the winding order right, and ignore providing the optional vertex normals.

Apart from parts of the geometry not displaying as expected in the world, is there some way to quickly work out (in the c++ code) which order the vertex indices should go to make it an anti clockwise triangle?

> **[Back-face culling](https://en.wikipedia.org/wiki/Back-face_culling)**
>
> In computer graphics, back-face culling determines whether a polygon of a graphical object is visible. It is a step in the graphical pipeline that tests whether the points in the polygon appear in clockwise or counter-clockwise order when projected onto the screen. If the user has specified that front-facing polygons have a clockwise winding, but the polygon projected on the screen has a counter-clockwise winding then it has been rotated to face away from the camera and will not be drawn.
> The pr...

[https://www.opengl.org/wiki/Face\_Culling](https://www.opengl.org/wiki/Face_Culling)
