# Procedurally created cube has flat shading / lighting and I don't know why

**URL:** <https://forums.unrealengine.com/t/procedurally-created-cube-has-flat-shading-lighting-and-i-dont-know-why/768734>\
**Category:** Blueprint\
**Tags:** development, Procedural-Generation, shading, procedural-mesh-comp, unreal-engine, cube, Lighting, procedural, Blueprint, question\
**Created:** [February 11, 2023, 5:51pm UTC](https://forums.unrealengine.com/t/procedurally-created-cube-has-flat-shading-lighting-and-i-dont-know-why/768734 "2023-02-11T17:51:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maderschaden](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Maderschaden](https://forums.unrealengine.com/u/Maderschaden)\
**Post date:** [February 11, 2023, 5:51pm UTC](https://forums.unrealengine.com/t/procedurally-created-cube-has-flat-shading-lighting-and-i-dont-know-why/768734/1 "2023-02-11T17:51:05Z")

</div>

Hi everybody.

I have a problem: I am trying to create a cube procedurally via the Procedural Mesh Component. The generation itself is working, but the problem is that my cube is totally flat-shaded and I really do not know one, though I suspect it has something todo with the UVs or normals of my mesh section. As you can see in the images, I have 8 vertices arranged to form the cube and I draw triangles between them all fine so far. But I really do not understand how to assign the UV coordinates to these 8 vertices correctly.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/d/5add8a0042955178058f0311d04a9ba6f8805cb0.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/a/7/da77f198bea113be3b3a65853322a7fb64ddd6db.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/8/c181a63f6e0c00088c91aa289cc7544a3f461f86.jpeg)

These are the normals which I am using, all pointing from the respective corner directly outwards:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/a/e/2ae616f7c25cb9a38803378bc07f545fdd1e6c68.png)

What I already tried was treating them as 2 seperate squares (bottom and top) and have them arranged between (0,0) and (1,1) like this:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/4/0/c40a8a0e1b83c8c945786fefecdee68f2684606b.png)  
But that just leads to the flat shaded outcome. Same happens for all (0,0) and all (1,1).

When I try to let the system calculate the normals and tangents like this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/8/4982a830a1c08f1a8d7c110b3b612a4f65ec76df.png)

The outcome looks totally weird:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/a/08a23ff3b07b49d34702d1c673c84e869ff04b52.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/c/96c559c8ee4b7033f1f6c91c5a38f9ec6a6f28fe.jpeg)

The problem is I do now about the usual Cube UV splitting thingy but I do not know how this applicable here. Because I only have 8 vertices and I cannot “split a vertex in half” so I do not know where on this uv system my vertices should lie. For example the right side of my cube is vertices (0,1,4,5) so I have don’t know where on my UV scale vertex 0 should lie, in the top right corner for the bottom face, or in the bottom left corner for the right side.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/5/415abec71e44753825f2ed267f5f0da822e844ef.png)

Because this is my current arrangement for the UV space:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/6/7/867ecbef790ffaf4172ef78aee356c37c23c132e.png)  
And I have no clue how and where the side faces lie in this. Can anybody help me with this?
