Is it possible to animate the vertex color of an object?
-
$\begingroup$ perhaps you could clarify on the basis of what you would like to animate it. A morph between two color layers, or something more procedural. $\endgroup$– zeffiiJun 14, 2013 at 8:00
-
$\begingroup$ two possibilities: - or to morph between two vertex colors layer in time - or to change , in same vertex color layer, the colors in time $\endgroup$– GabrielSJun 14, 2013 at 9:07
-
1$\begingroup$ please update your question with more details. $\endgroup$– ideasman42Jun 14, 2013 at 11:14
2 Answers
Cycles
In Cycles Render, it's rather easy. Create your two Color Layers and animate the MixRGB's Fac: value.
I'm not familiar enough with Blender Internal to find a suitable answer for that engine. Luckily, brecht provided an answer
Blender Internal
-
1$\begingroup$ A similar setup works for Blender Internal, using two Geometry nodes for the vertex color, a Mix node to mix them and a Material node to plug the color into. $\endgroup$– brechtJun 14, 2013 at 11:23
-
$\begingroup$ @brecht I tried and failed miserably, can you show a .blend? $\endgroup$– zeffiiJun 14, 2013 at 11:24
-
-
$\begingroup$ @brecht Thank you! I see, the viewport BI render doesn't seem to update (without switching from Render Preview to Texture Preview and back again), but a f12 regular render works fine. $\endgroup$– zeffiiJun 14, 2013 at 11:38
manipulating Color Layer directly with Python as a function of frame number
We can animate a color_layer vertex by vertex procedurally with frame_change_pre handler
, docs for which are here. This assumes that there is a vertex color map called 'Col', and that you know how to render Vertex Colors
import bpy
import random
obj = bpy.data.objects["Cube"]
mesh = obj.data
color_layer = mesh.vertex_colors["Col"]
def set_vcols(frame):
i = 0
for poly in mesh.polygons:
for idx in poly.loop_indices:
r = 0.5
g = 255 / (frame % 255)
b = random.random()
color_layer.data[i].color = r,g,b
i += 1
def my_handler(scene):
frame = scene.frame_current
set_vcols(frame)
bpy.app.handlers.frame_change_pre.append(my_handler)
If you go this route, while developing it might seem that your code is not being executed as you hoped, run the below code from console, then rerun your script:
purge the event list:
f_change = bpy.app.handlers.frame_change_pre
del f_change[0:len(f_change)]
-
$\begingroup$ Thanks but I'm not sure what can i make with this code. What are the steps to use this script? I have creat a cube, asign to it a vertex colors named "Col", run the script, but nothing appears $\endgroup$– GabrielSJun 14, 2013 at 7:29
-
$\begingroup$ I now how to render the vertex color, i want to animate this propertie: example: all vertex are red at 0s and all are greens at 1s $\endgroup$– GabrielSJun 14, 2013 at 9:02
-
-
-
$\begingroup$ Blender internal, but if there is a technique juste for cycle, i want to know too for my knoledge $\endgroup$– GabrielSJun 14, 2013 at 9:12