# How to Save Particle Combing Data to a Normal Map Image File in UV Space?

How can I extract the data created by a particle combing operation (on hair particles, for instance) to file (even if some Python code is required) in a 3-component RGB normal image map to UV space (when the unwrapping has already been done for the geometry), and then (that's a second question, I guess) feed it back to the particle system without having to recomb again?

I do not have an answer for you, although I can provide you with a few nuggets of info that will come in handy.

Here is some python code that shows you how to dump the coordinates of the root and tip of the hairs:

import bpy

def dump_particles(ps):
for p in ps.particles:
print(p.location)
#print(p.fuv)
print(p.hair_keys[-1].co_local)
print("_")

dump_particles(bpy.context.active_object.particle_systems[0])


The major stumbling block is that the barycentric coordinate of the hair is NOT exposed via the python API. (see also How do I comb hair in python?)

This makes calculating the position of the hair in UV coordinates much harder (although you could probably reverse-engineer it from the location if you are willing to do a lot of analytic geometry).

Even once you do figure out where the hair is in UV space, you'll need to choose how to interpolate to compute the values for the image you want to use as a normal map. (Maybe compute the dual of a voronoi diagram and use barycentric coordinates again).

• I'm checking this before the end of the week. I was thinking of voronoi too. Having the same problem in Houdini, BTW. Prefer to solve it in Blender, but VEX+COP might be easier than reverse engineering Blender's object model. Also, are you from this world? I was sort of prepared to give up on this thing! :D – Vincent Olivier Nov 25 '14 at 22:21
• I am from this world, but I have ventured deep into realms nobody else cares about and come back bearing grumpiness. It's an occupational hazard. – Mutant Bob Nov 26 '14 at 15:45
• Ah. I find it hard to believe. :D I don't know many people that are into writing AVC/HEVC NALs handlers from scratch just for fun. Anyways, I might have found a way to save 32-bit float OpenEXR normal maps from the comb tool in Houdini. I will be investigating this solution this week and see if what I learn is back-portable to Blender. – Vincent Olivier Dec 1 '14 at 17:41