0
$\begingroup$

I'm currently making use of the full RGBA components of vertex paint, where RGB stands for color and A for blend height inside a shader.

The shader basically uses alpha 0.0 to 1.0 to set different textures, where 0.0 to 0.25 is one texture, 0.25 to 0.5 is another, and so on.

RGB is used for light baking, so far, it's pretty optimal and runs smoothly inside the game engine.

The workflow is quite difficult to follow mostly because blender has Add Alpha & Erase Alpha as default, not a float grayscale functionality, I'd be willing to pay for an add-on that lets me work with an isolated alpha channel in exact values, there is currently one, called Vertex Color Master, but it's a bit outdated, not working properly with alpha, and the developer doesn't have much time to work on it.

If you have any suggestions or ideas to set exact values in the Vertex Alpha channel, I'd be very happy to hear ideas or suggestions.

I'd love to request the alpha float painting as a feature for the vertex paint tool in blender instead of the add/erase combo, but I don't really know who or where would be appropriate.

Regards.

$\endgroup$
5
  • $\begingroup$ Does it make more sense to have two color attributes: Color and BlendHeight, and paint in the (say) R channel of BlendHeight? At export time it would be easy to combine them like rgba = (color.r, color.g, color.b, blendheight.r). $\endgroup$
    – scurest
    Jan 6 at 15:38
  • $\begingroup$ It is an interesting proposal, the only issue still lies in having an extra vertex channel when there's an alpha still in blank, and generating another channel creates unnecessary data, I did have a look in tools to transfer vertex that (R to A for example), but that just makes the workflow more complicated for others to follow. $\endgroup$ Jan 10 at 12:43
  • $\begingroup$ You'd just ignore the channels you aren't using. For a game I imagine you have an automated asset pipeline. You would add the combination there along with any other data munging you need, not do it manually. $\endgroup$
    – scurest
    Jan 10 at 15:16
  • $\begingroup$ You can ignore the channels, but they'll get packed anyways, most game engines just import the model with the attributes they come, when the build is due some things do get optimized, but vertex channel isn't exactly one of them... $\endgroup$ Jan 11 at 14:17
  • $\begingroup$ Like I said, you should have an automated pipeline to do these things. Being able to munge your data into the exact form you want is the least of the benefits. But if you don't have one, yeah, using two attributes won't work. $\endgroup$
    – scurest
    Jan 11 at 14:32

1 Answer 1

1
$\begingroup$

I ended up doing this with a script

def set_vertex_alpha(alpha):
    # get the active object and its data
    obj = bpy.context.active_object
    mesh = obj.data

    # enter edit mode and get the bmesh
    bpy.ops.object.mode_set(mode='EDIT')
    bm = bmesh.from_edit_mesh(mesh)

    # make a list of selected vertices
    selected_verts = [v for v in bm.verts if v.select]

    # get the active vertex color layer
    col_layer = bm.loops.layers.color.active

    # assign the alpha value to the selected vertices, overwriting the existing values
    for vert in selected_verts:
        for loop in vert.link_loops:
            color = loop[col_layer]
            color[3] = alpha  # set the alpha value
            loop[col_layer] = color

    # update the mesh with the modified bmesh
    bmesh.update_edit_mesh(mesh)

    # exit edit mode
    bpy.ops.object.mode_set(mode='OBJECT')

To make this easier to use I also packed this up into an addon that let's you overwrites whatever alpha value you have in the selected vertices in case anyone ever needs it.

https://github.com/Desayuno64/VertexAlphaSetter

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .