GenerateNormals in a ForEach loop weirdness

In the Stride/Rendering/Dynamic Model demo called “How To Dynamic Model” there is something odd going on which I don’t quite understand. There is a ForEach loop which takes a spread of Vector3’s and the output of “GenerateNormals” and produces a spread of Pos3Norm3Tex2 values. The normals are the thing that confuses me. A normal can only be determined from 3 vertices so the first three vertices for instance all have the same normal which can only be calculated after all three vertices are seen. This means that the first and second outputs can only be completely set after the third output has been seen - but that’s just plain odd since, in my understanding, each input produces one output in the spread and the spread is setup by the ForEach loop. So how does The ForEach (or GenerateNormals) go back and retroactively set the normals for output elements 0 and 1 only after it’s seen input value 2? I can only imagine that somehow some buffer magic is going on so that somehow the buffers for elements 0 and 1 are still available for modification when vertex 3 is seen but since the ForEach loop is presumably the one who sets up the output spread and therefore is the only one that has access to the spread’s memory how is such a buffer possible? This seems like an interesting technique that I’d like to understand.
image

Seems you are confusing the cache region with a loop? GenerateNormals already did calculate everything based on the whole spread of vertices provided and is not part of any loop (see its output that is a spread of Vector3, that is the result of some internal loop most likely). the foreach loop below is just merging pos, normals and uvs into one datatype.

Oh - of course. Now I feel foolish! Leaving the post up just to shame myself!

no worries! keep digging:)