Can I use skin modifier to add material with texture?

I used a python script to create a simple skin modifier.
Can I use this to create a material with a UV texture based on this skin?
I asking because the skin modifier comes with strange geometry for a UV Map and I want to use it.
See the source code I used:

# add the skin modifier 
obj_branch.modifiers.new(name="SK", type="SKIN")
bpy.context.view_layer.objects.active = obj_branch  
# get the skin vertices layers
skin_vertices = obj_branch.data.skin_vertices
# get the layer
skin_layer = skin_vertices[0]
for i in range(1,branch+1):
    # assigns radius for each vertice to sized the branch 
    skin_layer.data[i-1].radius = (rand_list[i-1], rand_list[i-1]) 
    #Indices 0 and 1 are the vertex indices
    skin_layer.data[i].radius = (rand_list[i-1],rand_list[i-1])

bpy.ops.object.skin_armature_create(modifier="SK")

That’s a good question, you should try it and let us know if you run into any specific errors

I don’t understand your reply ?! “…you run into any specific errors”

Let me clarify: you’ve created a script that does something custom. You’re curious if this script will let you make materials using UV texturing. Rather than asking if your script can do this, why not just try it yourself? You already have the script loaded in Blender, so you’re more qualified to test it out than anyone else here. If you test it and something goes wrong, then we can help you, but right now, there’s nothing stopping you from answering your own question :slight_smile:

The question is more about the A.P.I. from Blender 3D can let access easier data to create UV texturing… The script I used is a basic skin modifier. Anyway, if I will have an answer I will share it. Thank you.

It can probably work, but you have to apply the modifier first.
Because the geometry is generated and doesn’t “really exist”, you can’t unwrap that unless the modifier is applied.

From there you can look for how to unwrap with python. 99% of what you can do in blender is reproducible in python. Sadly I don’t have the command in mind and I’m a bit lazy to look for that but that’s probably not to much complicated to find either.

You can also use generate UV coordinates to guide your texture’s mapping if you’re just looking for basic UV. Generated UV coordinates tend to produce crude results, but if you use some other settings, such as the Image Texture, Box Projection type, you can get a generated 3D, UV projection in the rough shape of a cube, dynamically.

1 Like

@sozap and @RPaladin give me some partial solutions.
I don’t find in the A.P.I. a method to generate a UV map based on a skin modifier.
Yes, the default way is to apply the modifier … if the object mesh “doesn’t have shape keys”. This is done.
I suppose the drawing of the skin is showing using the OpenGL.
After I apply the modifier the EDIT mode has all vertices and I suppose this can be used for UV Map.
Now I need to use these vertices to generate a good UV Map and used it with the material.
The default solution: “It can probably work, but you have to apply the modifier first.”

Yes, the solution provided by RPaladin is relevant too, you may not need UV’s to map the texture.

Well , it’s not exacly that , but you get the idea. This is how blender works. To do the unwrap blender need to have access to mesh data. Because the skin modifier generate proceduraly the mesh data, the faces generated by the modifier don’t really exist in edit mode. But after the generation it works like any other object.

Geometry nodes should be able to do this soon, UV unwrap and pack island node is not quite in yet though, and some stuff would work better with a cache, (to persistently get the same generated uv as frame 0)

1 Like