The goal of this script is to select all the shadow faces of a mesh. I use vertex color.
The principle: if a face is black then select it.
This way the user can have a set of selection based on the light source.
So here is the part of the script that don’t do exactly what it is supposed to:
me.vertexColors = 1
for f in me.faces:
for v in f.verts:
if f.col[1].r == 0:
print f.col
f.sel = True
The problem of this code is that it don’t really test all the vertex colors : it can select a face , even if it is not all black (i mean all the vertex of the face).
me.vertexColors = 1 #activate vertex color
for f in me.faces:
total = 0 # initialize the counter
col= f.col # get some mysterious value
for i, v in enumerate(f):
index = f.col<i>
redvalue = index.r
greenvalue = index.g
bluevalue = index.b
if redvalue+greenvalue+bluevalue <= 250: # this value define sensivity of the selection
total = total + 1 # increment the total of black vertex
if total == 4: #when there is 4 black faces
f.sel = True #select the face
AS i said it is the begining of an idea.
Ill show with use…
Easy features i want to add:
-make the vertex colors automatically (now i use blender interface)
-make the selection a new material index “[I]dark”
-invert and make a new index “light”
make a UI to alow sliding sensivity
More difficult:
call “seams from island” script
unwrapp the result with some optimised unwrapping script:
->all faces with the same size/shape, and luminosity are unwrapped in the same space.
( the ground squares on my exemple)