Thanks to help of shmuel I made a setup for interpolating a normal in geonodes. Ideally, it would reproduce Blender's smooth shading exactly. So I reproduced the setup in the Shading nodes. In order to access the vertex positions and values, I capture them in geonodes on face domain:
For this to work properly I triangulate first:
Now, the main shading tree is straight-forward, just read the attribute, offload the actual calculations to another tree "Smooth Shading", and use the result:
"Smooth Shading" tree is based on barycentric coordinates:
The "Triangle Area" tree:
This all works very well for most purposes, but isn't perfect, the Mix node is there to easily switch between the two and see the difference:
It's very subtle and not visible when actually used as a normal. And yet there is a difference and it's not some kind of super-subtle difference I got here:
It's more, my approach is a linear interpolation, but here's I think a quadratic interpolation? Which would mean I need to consider also further vertices? Just a guess... You can see it if you pass the normal through Vector Math: Wrap to generate lines. In linear interpolation they are straight, but as seen on the top of the head, the Blender's interpolation smooths the lines:
So what algorithm do you propose to reproduce the smooth shading exactly?









