Notifications
Clear all

[Closed] average vertex color to object color

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

Just make sure the vertex color channel exists and contains data. You can have multiple vertex color channels.

Great, perfect! How do I apply this to multiple selected objects at once? (average colour per object)