I needed to store both original and smooth vertex normals in a mesh for a shader-based effect, so I was looking for a way to bake normals to vertex colors in Blender 2.8.
Turns out baking to vertex colors didn’t survive Blender’s transition to 2.8, at least as of 2.81. There are workarounds like copying the contents of a texture to vertex colors (like this addon), but that seemed a bit clumsy for my needs.
Instead, I found a Python script on stackexchange that did pretty much what I needed. I figured this could be a good exercise for getting into addon development and turned the code there into a simple Blender addon. In the process, I also added the ability to swizzle the normals as they get stored in vcols, and an option to “bake” in either World Space or Local Space.
You can download the addon here.
As it’s really small, and all the code is contained in normals_to_vertex_colors.py, it’s probably a decent reference if you’re looking to learn how to write your own addons.