Page MenuHome

Geometry Nodes: Better support for byte colors.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Apr 20 2022, 3:48 PM.

Details

Summary

Since rBeae36be372a6: Refactor: Unify vertex and sculpt colors into new 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.

Diff Detail

Repository
rB Blender
Branch
update-attribute-conversion (branched from master)
Build Status
Buildable 21716
Build 21716: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Apr 20 2022, 3:48 PM
Jacques Lucke (JacquesLucke) created this revision.
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  • Merge branch 'master' into update-attribute-conversion
  • fix merge conflicts
  • add mix utils for byte colors
Jacques Lucke (JacquesLucke) retitled this revision from Geometry Nodes: Better support for byte colors. (WIP) to Geometry Nodes: Better support for byte colors..
source/blender/blenkernel/BKE_type_conversions.hh
5

I'm not thrilled about adding this fields header in such a general header, since it adds a dependency on the functions module for anything that includes BKE_type_conversions.hh.
I don't see other great options though.

source/blender/blenkernel/intern/mesh.cc
65

Is this necessary? It seems like this case should be covered by BLI_CPP_TYPE_MAKE(ColorGeometry4b, blender::ColorGeometry4b, CPPTypeFlags::BasicType)?

source/blender/makesrna/intern/rna_nodetree.c
2158

What about rna_GeometryNodeAttributeType_type_with_socket_itemf? A bit easier to see the difference that way IMO.

  • Merge branch 'master' into update-attribute-conversion
  • cleanup
source/blender/blenkernel/BKE_type_conversions.hh
5

Yeah, not sure where to put that either. I could make it a standalone function in a header that includes BKE_type_conversions.hh and FN_fields.hh, but not sure which one that should be.

source/blender/blenkernel/intern/mesh.cc
65

ah right, I added that in the beginning when I was still using MLoopCol instead of ColorGeometry4b.

  • remove unused header
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/blenkernel/BKE_type_conversions.hh
5

Maybe some file like BKE_type_conversions_field.hh? It could still be implemented in type_conversions.cc
A bit weird to have a header just for a single thing, but I don't really mind that, and FN_field.hh is sort of a large header.

This revision is now accepted and ready to land.Apr 21 2022, 4:03 PM
source/blender/blenkernel/BKE_type_conversions.hh
5

Hardly makes any difference now really. BKE_type_conversions.hh is only included in 6 translation units, and 5 of those include fields anyway. Only realize_instances.cc doesn't include fields yet from what I can tell.

source/blender/blenkernel/BKE_type_conversions.hh
5

If we want to separate this into a header with a single function, we should follow some rule that is applied in other places in Blender as well.