Download

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

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



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

I want to this:
2.jpg​​​​​​​

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

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.

Quick way? I think intricacy.

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: