It arguably reads easier if simple operations like reading from indices of an array don't each get their own line. Also the same corner attribute sampling was repeated in a few places. And add a new function to sample normals from the corner domain, and use lower level arguments to the lower level functions (i.e. not just a mesh pointer, but the necessary data arrays).