# Calculating Normals for UProceduralMeshComponent

**URL:** <https://forums.unrealengine.com/t/calculating-normals-for-uproceduralmeshcomponent/548012>\
**Category:** C++\
**Tags:** unreal-engine, UE4, question\
**Created:** [May 3, 2022, 8:20pm UTC](https://forums.unrealengine.com/t/calculating-normals-for-uproceduralmeshcomponent/548012 "2022-05-03T20:20:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pretzelman127](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pretzelman127](https://forums.unrealengine.com/u/Pretzelman127)\
**Post date:** [May 3, 2022, 8:20pm UTC](https://forums.unrealengine.com/t/calculating-normals-for-uproceduralmeshcomponent/548012/1 "2022-05-03T20:20:23Z")

</div>

I’m hoping someone can take a look at this and tell me which calculation I’m doing wrong or what I’m missing. I’m using ProceduralMesh to try and generate a terrain(hopefully infinite). I’m trying to apply this simple material that blends materials based on their vertexnormal.

 ![LandscapeMat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/c/2/2c2813d3b67a9a40c587ca4e62a91b24bc6e5a07.png)

Which works fine for a terrain generated using UEs built in landscape generator, but not my procedurally generated mesh. the generated mesh is the solid gray colored object.

 ![Lit](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/3/d/63d3e45965e378b7f1b2272f4a03d6327761b7fd.jpeg)

I had some issues figuring out normals, and I thought I’d figured it out, but looking at the buffer visualation (World Normal) inside the editor I see my generated mesh not projecting in the way the landscape was. the generated mesh is selected and highlighted in orange.

 ![WorldNormalBuffer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/0/4/004342cc80814086e7702f007c476fafa91f2449.jpeg)

Finally my code for the mesh generation. I’m sorry for poorly written code in advance.

 ![CreateMesh_Part1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/b/56bdc81971d03e56b207c8396938d3273d6c9952.png)

 ![CreateMesh_Part2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/a/8fa143c1981b9b19e029888ac4d0c5fe5dc3d170.png)  
esh\_Part1|674x500].(upload://cnlFoNVQZ6vDNy5fNZcJt5yxRu2.png)

I feel the algorithm is correct but it’s one of my calculations of the mesh data that I’m doing wrong. I think it’s something with my normal calculation, but not entirely sure.

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [May 3, 2022, 8:36pm UTC](https://forums.unrealengine.com/t/calculating-normals-for-uproceduralmeshcomponent/548012/2 "2022-05-03T20:36:14Z")

</div>

What happens if you don’t add the normals or tangents and let the CalculateTangentsForMesh() do it?

---

<div class="post-metadata">

**Author:** ![Pretzelman127](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pretzelman127](https://forums.unrealengine.com/u/Pretzelman127)\
**Post date:** [May 6, 2022, 1:34am UTC](https://forums.unrealengine.com/t/calculating-normals-for-uproceduralmeshcomponent/548012/3 "2022-05-06T01:34:03Z")

</div>

I had hoped that would work, but i must have been doing something wrong. Anyways, I solved my own issue and I had done everything correctly and just had not made a steep enough slope to get the slope blending materials.
