adds option to color attribute to override the attribute
This commit is contained in:
parent
9765e28786
commit
53366cc71d
2 changed files with 19 additions and 3 deletions
|
|
@ -29,6 +29,11 @@ class BakeToIDProperties(PropertyGroup):
|
||||||
name="Color Attribute",
|
name="Color Attribute",
|
||||||
default="ID_MASK",
|
default="ID_MASK",
|
||||||
)
|
)
|
||||||
|
target_vertex_color_override_attribute: BoolProperty(
|
||||||
|
name="Override Color Attribute",
|
||||||
|
default=True,
|
||||||
|
description="If set true, the attribute will be deleted and recreated, if it already exists. If set false, the data will just be overwritten."
|
||||||
|
)
|
||||||
|
|
||||||
adv_total_hues: IntProperty(
|
adv_total_hues: IntProperty(
|
||||||
name="Total Hues",
|
name="Total Hues",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ name = 'Color Attribute / Vertex Color'
|
||||||
description = 'Bakes the ID onto a color attribute (previously known as Vertex Color)'
|
description = 'Bakes the ID onto a color attribute (previously known as Vertex Color)'
|
||||||
|
|
||||||
connected_properties = [
|
connected_properties = [
|
||||||
'target_vertex_color_attribute_name'
|
'target_vertex_color_attribute_name',
|
||||||
|
'target_vertex_color_override_attribute'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,12 +22,22 @@ def paint_targets(props, targets, colors):
|
||||||
|
|
||||||
layer_name = props.target_vertex_color_attribute_name
|
layer_name = props.target_vertex_color_attribute_name
|
||||||
for mesh in sorted_targets:
|
for mesh in sorted_targets:
|
||||||
|
|
||||||
if layer_name in mesh.attributes:
|
if layer_name in mesh.attributes:
|
||||||
mesh.attributes.remove(mesh.attributes[layer_name])
|
mesh.attributes.remove(mesh.attributes[layer_name])
|
||||||
|
|
||||||
color_attribute = mesh.attributes.new(name=layer_name, type='FLOAT_COLOR', domain='CORNER')
|
color_attribute = get_color_attribute(props, mesh.attributes, layer_name)
|
||||||
|
|
||||||
for (indecies, color) in sorted_targets[mesh]:
|
for (indecies, color) in sorted_targets[mesh]:
|
||||||
for polygon in indecies:
|
for polygon in indecies:
|
||||||
for idx in polygon.loop_indices:
|
for idx in polygon.loop_indices:
|
||||||
color_attribute.data[idx].color = (color[0], color[1], color[2], 1.0)
|
color_attribute.data[idx].color = (color[0], color[1], color[2], 1.0)
|
||||||
|
|
||||||
|
def get_color_attribute(props, attributes, layer_name):
|
||||||
|
if layer_name in attributes:
|
||||||
|
if not props.target_vertex_color_override_attribute:
|
||||||
|
return attributes[layer_name]
|
||||||
|
|
||||||
|
attributes.remove(attributes[layer_name])
|
||||||
|
|
||||||
|
return attributes.new(name=layer_name, type='FLOAT_COLOR', domain='CORNER')
|
||||||
Loading…
Add table
Add a link
Reference in a new issue