Notifications
Clear all
[Closed] average vertex color to object color
Jul 26, 2017 3:32 am
Hi, could somebody help me with a script to change a selected object’s objectcolor to the average of the object’s vertex color? thanks!
3 Replies
Jul 26, 2017 3:32 am
fn avgVertexColor obj = (
local tmp = snapshotAsMesh obj
avg = [0,0,0]
for i=1 to tmp.numverts do avg += getvertcolor tmp i
avg = avg / tmp.numverts
free tmp
delete tmp
avg as color
)
$.wirecolor = avgVertexColor $
Jul 26, 2017 3:32 am
Just make sure the vertex color channel exists and contains data. You can have multiple vertex color channels.
Jul 26, 2017 3:32 am
Great, perfect! How do I apply this to multiple selected objects at once? (average colour per object)