Hello! Just get it on with this code
void AProceduralSphere::GenerateUVs(const int Slices, const int Stacks, const TArray<FVector>& SphereVertices, TArray<FVector2D>& SphereUVs)
{
const auto textureCellsCount = 16;
const auto uvXStep = 1.f / Slices;
const auto uvYStep = 1.f / Stacks;
auto uvX = 0.f;
auto uvY = 0.f;
// add top vertex
SphereUVs.Add(FVector2D(0, 0.5f));
// generate vertices per stack / slice
for (int32 i = 0; i < Stacks - 1; i++) {
uvX = 0;
uvY += uvYStep;
for (int32 j = 0; j < Slices; j++) {
uvX += uvXStep;
SphereUVs.Add(FVector2D(uvX, uvY));
}
}
// add bottom vertex
SphereUVs.Add(FVector2D(1, 0.5f));
}
One important thing - if you want to solve artifact on top and bottom caps, then you need to have one cap vertice for each slice. This is needed because one vertice just cant have more than one UV coords, while here wee need them. By the way, for that reason, every UV seam vertices are stored with more than one instance when render works
