3
$\begingroup$

So what I want to create vertex paint gradient from selected edge loops like this:

enter image description here

In this picture I did with brush, but I have some bigger models so it could be tedious. I know you can do this in weight paint like this:

enter image description here

So maybe a script that converts weight paint into vertex paint would be helpful?

$\endgroup$
1
$\begingroup$

To make the gradient as the result of the vertex paint assign a texture as a pattern to the brush or use weight paint and convert it into the vertex painted colors.

Painting vertex colors with brush pattern

  1. In Edit mode select faces which you'd like to be affected by Vertex paint. Go to Vertex Paint mode and enable the Face Selection Masking option to make the selected faces be the only ones affected.
  2. In the brush settings, Texture rollout assign texture with desired effect. If the resulted vertex colors should be gradient-like, procedural texture of the Blend type will be good enough.
  3. Choose Stencil option to paint with texture in the same way as in Texture Painting. Move it in the 3D Viewport with RMB to set up painting as desired.

    GIF vertex painting with brush pattern

Converting Weight Paint into desired vertex colors

There's an addon for converting weight paint into vertex colors and vice versa.

  1. After activating it, create a weight paint to be converted. Use Weight Gradient, Quantize tools etc. from the Toolshelf to create the final result.
  2. In the Vertex Colors mode, 3d Viewport header find and run Paint > WeightToVertexColor.
$\endgroup$
1
$\begingroup$

This script lets you color the vertices associated with any selected geometry.

import bpy
import random


def set_verts_colors(new_color):

    # must switch to Object Mode briefly to get the new set of selected elements
    # and then change the vertex_color layer
    bpy.ops.object.mode_set(mode='OBJECT')
    obj = bpy.context.active_object

    mesh = obj.data
    color_layer = mesh.vertex_colors.active  
    selected = set(v.index for v in obj.data.vertices if v.select)

    i = 0
    for poly in mesh.polygons:
        for loop_index in poly.loop_indices:
            vidx = mesh.loops[loop_index].vertex_index            
            if vidx in selected:
                color_layer.data[i].color = new_color
            i += 1

    # set to vertex paint mode to see the result
    # bpy.ops.object.mode_set(mode='VERTEX_PAINT')
    bpy.ops.object.mode_set(mode='EDIT')


set_verts_colors(new_color=(1,0.5,0.6))

Note: there is currently no mechanism to select verts or edges individually while in Vertex Paint mode, but you can view Vertex colors while in Edit Mode.

enter image description here

as an Add-on

An Add-on might already exist that does this either as a feature, or sole purpose - If so, I couldn't find it. Below you'll find the same script converted into an add-on (installation just like any other add-on).

code hosted on GitHub, or convenient download link

trigger via Spacebar -> Set VCols of any Geometry, or add a shortcut yourself.

enter image description here

press escape to leave the VCols unchanged, press OK to set them with the picked Color.

enter image description here

becomes

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.