How do I shade a patch

Maybe this post is helpful, which shows a code snippet how to reshape the unfolded patches back to their original.