{"id":116,"date":"2020-03-01T16:37:37","date_gmt":"2020-03-01T16:37:37","guid":{"rendered":"http:\/\/philippseifried.com\/blog\/?p=116"},"modified":"2020-03-01T16:37:37","modified_gmt":"2020-03-01T16:37:37","slug":"blender-addon-normals-to-vertex-colors","status":"publish","type":"post","link":"https:\/\/philippseifried.com\/blog\/2020\/03\/blender-addon-normals-to-vertex-colors\/","title":{"rendered":"Blender Addon: Normals to Vertex Colors"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/github.com\/Philipp-Seifried\/Blender-Normals-To-Vertex-Color\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"412\" src=\"http:\/\/philippseifried.com\/blog\/wp-content\/uploads\/2020\/03\/normals_to_vertex_colors.gif\" alt=\"\" class=\"wp-image-117\"\/><\/a><\/figure>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Turns out baking to vertex colors didn&#8217;t survive Blender&#8217;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 <a href=\"https:\/\/github.com\/danielenger\/Bake-to-Vertex-Color\">this addon<\/a>), but that seemed a bit clumsy for my needs.<\/p>\n\n\n\n<p>Instead, I <a href=\"https:\/\/blender.stackexchange.com\/questions\/32584\/set-vertex-normals-to-vertex-color-in-python\">found a Python script on stackexchange<\/a> 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 &#8220;bake&#8221; in either World Space or Local Space.<\/p>\n\n\n\n<p><strong>You can <a href=\"https:\/\/github.com\/Philipp-Seifried\/Blender-Normals-To-Vertex-Color\">download the addon here<\/a>. <\/strong><\/p>\n\n\n\n<p>As it&#8217;s really small, and all the code is contained in <a href=\"https:\/\/github.com\/Philipp-Seifried\/Blender-Normals-To-Vertex-Color\/blob\/master\/normals_to_vertex_colors.py\">normals_to_vertex_colors.py<\/a>, it&#8217;s probably a decent reference if you&#8217;re looking to learn how to write your own addons.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t survive Blender&#8217;s transition to 2.8, at least as of 2.81. There are workarounds like copying [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11,10],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-addon","tag-blender"],"_links":{"self":[{"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":3,"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/posts\/116\/revisions\/120"}],"wp:attachment":[{"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/philippseifried.com\/blog\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}