Image Pixels to Vertex Weight

Hi, I need to recreate one technical visualization into vector file.
I was thinking about particles and weight map to generate size and color of arrows.
I was able to

  • separate colors from original Image (left) for image texture(right)
  • create exact grid -each particles/arrow is palced in center of a face
    Now I wanted to convert (somehow) texture to vertex weight map, because this texture use the same spectral gradient like weight does.

Thank you for help - ideas


Have a look at the UV texture to Vertex color script:
http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/UV/Bake_Texture_to_Vertex_Colors

i bet you can use that with some modifications, like stripping blending modes and make it use vertex weight instead of vertex color.

:slight_smile: thanks for tip
In my case - I don’t have knowledge to create or modify scripts . . . what a shame :slight_smile: Hm

well, you need a different approach anyway, as vertex weights aren’t loop-based but vertex-based (hence no sharp edges).

vertex group creation e.g.:

group = ob.vertex_groups.new("NewGroup")
for v in ob.data.vertices:
    group.add(v.index, WEIGHT, 'REPLACE')

Here’s a really rough test:
http://www.pasteall.org/36410/python

For proper conversion, it would have to turn RGB texture into grayscale using luminance and interpolate the uv/loop values for same vertex. Dunno if it’s still useful for you.

I will test it tomorrow, thanks for your interest.
(I’m busy with some deadlines at work for a last few days. So sorry for a bit late answer.)

I found some workaround with dynamic paint that generates vertex weight. But for that I had to convert RGB to greyscale image too. This image is used as displace texture for dynamic brush. It works, but with this greyscale texture I can directly control particle emission in a proper way :slight_smile:

For conversion spectral gradient to greyscale one - luminance is not good solution. Red color in this conversion is not represented by white color as I need to be. I used my own setup. I will post it soon.

Anyway, if there is an option to use spectral image directly used by script to generate weight would be cool :slight_smile:

Absence of sharp edges is not problem - my interest is in vertex informations - weight and color. The right image in my first post is not result that I’m asking for, it’s a reference image for vertecies. Original image is quite small so just preserve my precise grid catch grey (or antialias) pixels from image background I did it.

Not 100% if it’s what you need, but here’s one method:

You can convert an image (or image sequence) to Vertex Weights with the Vertex Weight Mix modifier. This is all I needed to do just now:

1: Create 2 vertex groups, assign all vertices to both. One with 0 weights, one with 1 weights.
2: Create the VWM-modifier. Enter the 1-group as A, the 0-group as B
3: Enter your texture as Texture Mask.

In my test file, this results in the 1-group carrying the modification.

When setting it to use the texture’s hue channel, it looks like it’s the same color/weight relationship as in Vertex Paint.
Here’s a screen of my quick test:


Pre-post addendum: Ah. You can simply bake the effect by applying the modifier, and the colors in Vertex Weight Paint look like they match your texture.

2 Likes

Oh!!! That’s what I was looking for :slight_smile: Thanks dude :slight_smile: I’m going to test it.

@encn, thanks from me too. has application to something I’ve been grinding on.

btw

slight correction to earlier post, group.add takes a list. To add all verts to vgroup “All” with weight WEIGHT


group = ob.vertex_groups.new("All")
group.add([v.index for v in ob.data.vertices], WEIGHT, 'REPLACE')

@encn: ok, I got some problem. Hue scale is not the same as spectrum scale.
Is there any chance to fix this issue in modifier setup? Thanks

http://blender.howto.cz/test-WeghtModifier/Color-Scales.gif

For now is better to convert spectrum scale to greyscale via Index color Table and use it as texture for modifier.