1
$\begingroup$

I’ve been given a task by the game programming team to create a shape with vertex color and alpha values on designated vertices.

I managed to crack the vertex color part of the task, unfortunately I can't set alpha value on vertices.

From what I’ve learned there are some plugins (mostly paid) for that. I don’t have a problem with purchase but I'm looking for the simplest solution, not some overly complicated tool.

The first 3 digits are RGB values. The fourth one is the alpha value and that's the one I have a problem with.

The first 3 digits are RGB values. The fourth one is the alpha value and that's the one I have a problem with.

$\endgroup$

2 Answers 2

0
$\begingroup$

Here's another way.

Go to Vertex Paint mode and select the vertices whose alpha you want to set. Open the Text Editor, paste this script, set the alpha value on the first line to what you want, and run the script to set all those vertices' alpha.

ALPHA = 0.42

import bpy
assert bpy.context.mode == 'PAINT_VERTEX'
mesh = bpy.context.object.data
ca = mesh.color_attributes.active_color
if ca.domain == 'POINT':
    for vi, v in enumerate(mesh.vertices):
        if v.select:
            ca.data[vi].color[3] = ALPHA
elif ca.domain == 'CORNER':
    for li, l in enumerate(mesh.loops):
        if mesh.vertices[l.vertex_index].select:
            ca.data[li].color[3] = ALPHA

You can keep selecting vertices, changing ALPHA, and running the script to set all the vertices you want.

$\endgroup$
1
$\begingroup$

Unless I'm mistaken, even in Blender 3.6, the Alpha of Vertex-Colors, (now Color Attributes) are not fully integrated into the painting system.

You can use Add Alpha and Erase Alpha Blend Modes in Vertex Paint. Starting from a known 0 or 1, you can give your (masked) vertices a quick dab with a brush at 0.5 strength in those modes.. but the feedback isn't there to know you've hit the spot exactly.

Checking via Geometry Nodes, actually the values are very slightly out. So instead, for a job like this, you could perhaps set up 4 Vertex Groups: R,G,B, and A. You can assign all vertices to all groups, and edit their values directly in Edit Mode, viewing the result in a simple material, previewed:

enter image description here

.. having combined the weights from the groups into a Color Attribute, using Geometry Nodes:

enter image description here

The combination can be stored as Byte Color on Face Corners of your mesh, and should export OK.

Until the system is more integrated, at least this get-around gives you positive control, and lets you see what you're doing.

$\endgroup$

You must log in to answer this question.

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