2
$\begingroup$

In blender you can color the vertexes. But is there a way to color the faces so the faces have only one color instead of the colors being interpolated based on the colors of the surronding verticies. This is avalible in maya ( https://youtu.be/TxlASKUMgfo?t=1m10s ).

$\endgroup$
  • $\begingroup$ Looks like you're searching for a way to make per-face vertex colors, not per-vertex. A scripted solution could help. You could make it with UI but it will be kind of a hack (but workable). $\endgroup$ – Mr Zak May 25 '17 at 12:40
  • $\begingroup$ @MrZak how would I do it with UI? $\endgroup$ – VinnieH01 May 25 '17 at 12:52
  • $\begingroup$ Using another answer from that question; maybe it provides you with something applicable for you case. $\endgroup$ – Mr Zak May 25 '17 at 13:22
  • $\begingroup$ @MrZak not really but I found out that I can use the face selection mask to paint individual faces without interpolation. This is however extreamly slow when you have a lot of polygons since you have to select them all one by one. $\endgroup$ – VinnieH01 May 25 '17 at 16:19
  • $\begingroup$ You can assign a material to each face. This answer automates the task. $\endgroup$ – sambler May 27 '17 at 2:58
3
$\begingroup$

You can achieve this using Texture Paint and a carefully crafted UV map with each face taking up the space of only one pixel. This will mean that the entire face relates to a single pixel in the image texture and is therefore painted a single consistent color. The UV map and the associated image can be created with a script.

Open a Text window, click New, give it a name such as 'create_pixel_uv.py', and paste the following script :

# Run this script to generate a UV map and Image with 1 pixel per face so each face has a single colour.
# NOTE : For Texture paint you need to set Option/Bleed to not more than 2px - otherwise you'll get bleeding into unrelated faces

import bpy
import bmesh
import math

# Get selected/active object
obj = bpy.context.object
obj.update_from_editmode()
bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(obj.data)

# Get count of faces
num_faces = len(bm.faces)

# Create image with 1 pixel per face (ie, WxH = <numfaces>x1)
image = bpy.data.images.new("facepixels_"+str(num_faces), width=num_faces*3, height=3)

# Create UV map
obj.data.uv_textures.new("facepixels_"+str(num_faces))
uv_layer = bm.loops.layers.uv[0]
bm.faces.layers.tex.verify()

# Process each face and position each loop vertex around the centre point
# of the central pixel of each 3x3 pixel group.
faceidx = -1
for f in bm.faces:
    faceidx = faceidx + 1
    loopidx = -1
    numverts = len(f.loops)
    for l in f.loops:
        loopidx = loopidx + 1
        luv = l[uv_layer]
        luv.uv[0] = (float(faceidx)+1.5+math.cos(float(loopidx)/numverts*math.pi*2+math.pi/4)/50)/num_faces
        luv.uv[1] = (0.0 + 0.5+math.sin(float(loopidx)/numverts*math.pi*2+math.pi/4)/30/3)

Select the object you want to "face paint" and click Run Script.

The script should create you a new UV map named 'facepixels_nnnn' (where 'nnnn' is the number of faces in your mesh) along with an image of the same name.

In the UV Editor window you'll see that each face has been sized and positioned to be within a single pixel in the image, in one long row. Each pixel has a border of 'unused' pixels around it to allow for 'bleeding' around the face during texture painting.

uv map

Ensure the new UV map is selected as the 'active' UV map.

Create a new material for the mesh and add an Image Node and select the new image. You should now be able to use Texture Paint to paint on the mesh with each face being painted a uniform color.

painting

Note the bleeding of color around the UV mapped pixels (the dot visible in the centre of each block of color on the UV image). The bleeding can be avoided by setting the Texture Paint Option/Bleed to 0px - although it won't be used in the render since it is outside the UV mapped faces.

aniimated

NOTE : Once you have painted your mesh you should Save or Pack your image so it is not lost when the Blend file is saved and reopened.

$\endgroup$
  • $\begingroup$ This should work. I still want all the colors to be in the vertexes though. All I would have to do is bake the texture to the vertex colors after I'm done painting. $\endgroup$ – VinnieH01 May 27 '17 at 7:30
3
$\begingroup$

Adjacent faces can have different plain colors, and a vertex can have a different color for each face it participates to.

In 2.79, it's possible to select the faces in Vertex Paint mode, and use 'Set Vertex Colors' (Header > Paint menu or Shift-K).

enter image description here

Likely the integration in Blender of a separate script that was used before.

Edit:

  • To view colors in the 3D editor when 'Material' display mode is selected, the option 'Vertex Color Paint' must be enabled for the material used (Properties editor > Material tab > Options panel).

  • The 'Face Selection Masking for Painting' button must be down in the 3D Editor header (Vertex Paint mode).

$\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.