I apply a 3D Voronoi pattern to a mesh. With these loops I can calculate the cell position, an ID and the distance.

But I would like to calculate a norm based on the generated pattern.

How can I use this pattern and the associated cells to create a normality or to realign the current normality?

The goal is to give the net a faceted look. The normals of each cell should point in the same direction and adjacent cells should point in different directions. These directions should be based on the original mesh standards. I do not want to completely break up mesh normals and have these points in random directions.

That's how I generate the Voronoi pattern.

```
float3 p = floor(position);
float3 f = frac(position);
float id = 0.0;
float distance = 10.0;
for (int k = -1; k <= 1; k++)
{
for (int j = -1; j <= 1; j++)
{
for (int i = -1; i <= 1; i++)
{
float3 cell = float3(float(i), float(j), float(k));
float3 random = hash3(p + cell);
float3 r = cell - f + random * angleOffset;
float d = dot(r, r);
if (d < distance)
{
id = random;
distance = d;
cellPosition = cell + p;
normal = ?
}
}
}
}
```