diff options
author | Jacques Lucke <jacques@blender.org> | 2022-04-21 17:11:26 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-04-21 17:11:26 +0300 |
commit | b9799dfb8a78dddbb3591dcb3e0b4de954c80fee (patch) | |
tree | 531a96e1ff7774b07ae1c91a4242c86d7d7f156e /source/blender/nodes | |
parent | aca083fbf38246437caa6e50a6feeeb23b64ee18 (diff) |
Geometry Nodes: better support for byte color attributes
Since {rBeae36be372a6b16ee3e76eff0485a47da4f3c230} the distinction
between float and byte colors is more explicit in the ui. So far, geometry
nodes couldn't really deal with byte colors in general. This patch fixes that.
There is still only one color socket, which contains float colors. Conversion
to and from byte colors is done when read from or writing to attributes.
* Support writing to byte color attributes in Store Named Attribute node.
* Support converting to/from byte color in attribute conversion operator.
* Support propagating byte color attributes.
* Add all the implicit conversions from byte colors to the other types.
* Display byte colors as integers in spreadsheet.
Differential Revision: https://developer.blender.org/D14705
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index 92614d1a31d..b51fc063ab8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -5,6 +5,8 @@ #include "NOD_socket_search_link.hh" +#include "BKE_type_conversions.hh" + #include "node_geometry_util.hh" namespace blender::nodes::node_geo_store_named_attribute_cc { @@ -55,7 +57,8 @@ static void node_update(bNodeTree *ntree, bNode *node) nodeSetSocketAvailability(ntree, socket_vector, data_type == CD_PROP_FLOAT3); nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT); - nodeSetSocketAvailability(ntree, socket_color4f, data_type == CD_PROP_COLOR); + nodeSetSocketAvailability( + ntree, socket_color4f, ELEM(data_type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)); nodeSetSocketAvailability(ntree, socket_boolean, data_type == CD_PROP_BOOL); nodeSetSocketAvailability(ntree, socket_int32, data_type == CD_PROP_INT32); } @@ -149,6 +152,12 @@ static void node_geo_exec(GeoNodeExecParams params) case CD_PROP_COLOR: field = params.get_input<Field<ColorGeometry4f>>("Value_Color"); break; + case CD_PROP_BYTE_COLOR: { + field = params.get_input<Field<ColorGeometry4f>>("Value_Color"); + field = bke::get_implicit_type_conversions().try_convert(field, + CPPType::get<ColorGeometry4b>()); + break; + } case CD_PROP_BOOL: field = params.get_input<Field<bool>>("Value_Bool"); break; |