# I need graphics expert. How set mesh vertex normals? (not's material normal map)

**URL:** <https://forums.unrealengine.com/t/i-need-graphics-expert-how-set-mesh-vertex-normals-nots-material-normal-map/141530>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 15, 2020, 2:54am UTC](https://forums.unrealengine.com/t/i-need-graphics-expert-how-set-mesh-vertex-normals-nots-material-normal-map/141530 "2020-04-15T02:54:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamdev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dreamdev](https://forums.unrealengine.com/u/dreamdev)\
**Post date:** [April 15, 2020, 2:54am UTC](https://forums.unrealengine.com/t/i-need-graphics-expert-how-set-mesh-vertex-normals-nots-material-normal-map/141530/1 "2020-04-15T02:54:06Z")

</div>

UProceduralMeshComponent is that allows you to specify custom triangle mesh geometry.

```auto

void UProceduralMeshComponent::CreateMeshSection_LinearColor(int32 SectionIndex, const TArray<FVector>& Vertices, const TArray<int32>& Triangles, const TArray<FVector>& Normals, const TArray<FVector2D>& UV0, const TArray<FLinearColor>& VertexColors, const TArray<FProcMeshTangent>& Tangents, bool bCreateCollision)

```

So,it’s working.

But see that parameters: const TArray\<FVector\>& Normals

All vertex normals same direction for now I can do. like this :  
​​​​​​​ ![1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/0/e0202e8b7df7551f2d0c1480b96b3962803b4e3d.jpeg)

I want to this:  
 ![2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/d/e/de9f90a16ed09ac2db55adb813ae26d6d2208df0.jpeg)​​​​​​​

So…  
What’s the calculation? how these data interact?

---

<div class="post-metadata">

**Author:** ![glib](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@glib](https://forums.unrealengine.com/u/glib)\
**Post date:** [April 16, 2020, 11:53pm UTC](https://forums.unrealengine.com/t/i-need-graphics-expert-how-set-mesh-vertex-normals-nots-material-normal-map/141530/2 "2020-04-16T23:53:11Z")

</div>

You want to get two normals on the ‘plane’ of the vertex, the take the cross product to get the normal of that plane (which is the normal of that vertex).

I’m not sure what data you’re using to drive this mesh right now, but you want to sample it at 4 points around your point, make two vectors out of those 4 points and cross them.

---

<div class="post-metadata">

**Author:** ![dreamdev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dreamdev](https://forums.unrealengine.com/u/dreamdev)\
**Post date:** [April 17, 2020, 9:52am UTC](https://forums.unrealengine.com/t/i-need-graphics-expert-how-set-mesh-vertex-normals-nots-material-normal-map/141530/3 "2020-04-17T09:52:21Z")

</div>

Quick way? I think intricacy.

 ![1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/6/860421ff23a83d1058312e34f1aaff4a9789d1bf.jpeg)

---

<div class="post-metadata">

**Author:** ![glib](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@glib](https://forums.unrealengine.com/u/glib)\
**Post date:** [April 18, 2020, 5:58am UTC](https://forums.unrealengine.com/t/i-need-graphics-expert-how-set-mesh-vertex-normals-nots-material-normal-map/141530/4 "2020-04-18T05:58:20Z")

</div>

In that particular quad’s case:  
FVector First = Triangles[1] - Triangles[0];  
FVector Second = Triangles[2] - Triangles[0];  
Normals[0] = FVector.CrossProduct( First, Second ).Normalized();

---

<div class="post-metadata">

**Author:** ![dreamdev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dreamdev](https://forums.unrealengine.com/u/dreamdev)\
**Post date:** [April 21, 2020, 3:13am UTC](https://forums.unrealengine.com/t/i-need-graphics-expert-how-set-mesh-vertex-normals-nots-material-normal-map/141530/5 "2020-04-21T03:13:08Z")

</div>

> [@glib](#):
>
> In that particular quad’s case:  
> FVector First = Triangles[1] - Triangles[0];  
> FVector Second = Triangles[2] - Triangles[0];  
> Normals[0] = FVector.CrossProduct( First, Second ).Normalized();

Very thankful!  
I searched lots of related information, but I couldn’t understand it.

I try another way:  
Build height map in C++  
UTexture2D \*HeightMapData;

Create normal maps from height maps in material:

 ![15874375491.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/8/2882dca1f3fd92170edb14c4c2d028af4765edb4.jpeg)
