Also how to use the āCurvatureā vertex color data with Cycles, just add an āAttributeā node with the name āCurvatureā.
edit: Looks like the alpha is actually working, setting it to zero makes the whole object disappear! :spin:
So thatās something I need to fix.
edit2: Should be ok now.
Ok, thank you for informing me. I got to test it on another machine with a fresh install of Blender. Canāt figure out whatās going wrong there.
edit: Ok, I reproduced your problem. Seems Iām using a Github version that has the 4 element RGBA. Even the newest Blender 2.79 is still using just 3 element RGB.
Added smoothing functionality. Currently developing on the dev branch, donāt know if the vertex color update from RGB to RGBA has yet been implemented in 2.79a. So might have to download a dev build to test out this.
Itās really necessary for big and/or jagged meshes. Hereās a 500k face object with 0 smoothing, and then with 20 smoothing.
thanks for sharing weād like to work on Curvature too in scatter but with weight painting weād definitely looking to convert your script but for weight paint
in the meanwhile we did some really simple fct that may interest some of the readers
it simply reads edge sharpness value with a multiplier
def create_sharpness_data(vg_name, factor=1):
"""simple sharpness"""
o = bpy.context.object
ob = o.data
bm = bmesh.new()
bm.from_mesh(ob)
bm.verts.ensure_lookup_table()
values=[v.calc_shell_factor()-1 for v in bm.verts]
bm.free()
if vg_name not in o.vertex_groups:
vg = o.vertex_groups.new(name=vg_name)
else: vg = o.vertex_groups[vg_name]
for i,v in enumerate(values):
vg.add([i], v*factor, 'REPLACE')
thanks @ambi , Iāll look at your library asap ! amazing work btw
curious to compare performance, i already got some great results with numpy before
in the meanwhile i did my own (more simple) fct, it just loop over bmesh edges look for angle and loop over verts again
wanted to optimize it with numpy but it seem that bmesh donāt get foreach_get API (still learning)
def eval_percentage(maxi, mini, nbr):
"""get weight value proportional to min and max"""
zone = (maxi-mini)
if zone==0:
return 1.0
r = (nbr-mini)/zone
return r
def create_curvature_data(vg_name, crop_max=1.0, mode='concave'):
"""create curvature data weight group, mode arg in ( 'concave','convex','both','curvature')"""
o = bpy.context.object
bm = bmesh.new()
bm.from_mesh(o.data)
bm.edges.ensure_lookup_table()
bm.verts.ensure_lookup_table()
#get all angle (and index by order)
angl = [e.calc_face_angle_signed(0.0) for e in bm.edges]
#find min and max values
mini = min(angl)/crop_max
maxi = max(angl)/crop_max
#curvature mode need 0.5 as flat, cannot take raw min/max
if mode=='curvature':
maxv = abs(mini) if (abs(mini)>abs(maxi)) else abs(maxi)
v_dict={}
#loop over dict, don't calculate all over angle again...
for i,v in enumerate(angl):
#evaluate values from min and max
if mode=='curvature':
val = eval_percentage( maxv, -maxv, v)
elif mode=='convex':
val = eval_percentage( maxi, 0, v)
elif mode=='concave':
val = 1-eval_percentage( 0, mini, v)
elif mode=='both':
val = eval_percentage( maxi, 0, abs(v))
for v in bm.edges[i].verts:
#if value already exist in dict, round both
if v.index in v_dict:
#if curvature, do average
if mode=='curvature':
old_val=v_dict[v.index]
del v_dict[v.index]
v_dict[v.index]= (val+old_val)/2 #average = create weird artifact ???
continue
#else only take max value
else:
if v_dict[v.index]<val:
del v_dict[v.index]
else:
continue
v_dict[v.index]=val
bm.free()
if vg_name not in o.vertex_groups:
vg = o.vertex_groups.new(name=vg_name)
else: vg = o.vertex_groups[vg_name]
for i,v in v_dict.items():
vg.add([i], v, 'REPLACE')
return
The smoothing function is probably what would give you the most value, as with angle calculation you will only get a very rough approximation of the surface curvature. With smoothing you can have many different types of appearances.