Page MenuHome

Geometry Nodes: Trace Image Node (WIP)
Needs RevisionPublic

Authored by Jarrett Johnson (jarrett.johnson) on Oct 29 2021, 6:46 AM.
Tokens
"Burninate" token, awarded by caneraslan."Love" token, awarded by Apofis."Burninate" token, awarded by baoyu."Love" token, awarded by dreamak."Love" token, awarded by emilisb."Love" token, awarded by blueprintrandom."Love" token, awarded by Dangry."Love" token, awarded by kuboa."100" token, awarded by mmaker."Love" token, awarded by Raknaar."Love" token, awarded by Roughyyy."Piece of Eight" token, awarded by duarteframos."Love" token, awarded by Schamph."Love" token, awarded by wilBr."Burninate" token, awarded by DiogoX2."Love" token, awarded by asmitty."Burninate" token, awarded by kursadk.

Details

Summary

This patch introduces a new node called Trace Image which traces a curve from an image. The underlying tracing is primarily done via *potrace*, a tool which converts bitmap images into scalable vector graphics. A very similar approach is done in the Grease Pencil module, and much of the setup code was ported from there with some slight modifications to use in Geometry Nodes context.

Design task: T92461

Some things I'm not too sure of and would like feedback on:

  • Category for this node. *Curve* seems to be the most appropriate category for a lack of an Image one.
  • Grease pencil has support for image sequences. Is this something we should also support? If so, what form would that take.

Diff Detail

Repository
rB Blender
Branch
trace_image (branched from master)
Build Status
Buildable 18306
Build 18306: arc lint + arc unit

Event Timeline

Jarrett Johnson (jarrett.johnson) created this revision.

Image Texture node has a Frame socket for image sequences but I'd imagine there is less need for that here.

Hans Goudey (HooglyBoogly) requested changes to this revision.Nov 2 2021, 5:23 AM

I really like the idea of this node. Glad to see it being worked on. Even though I see it's WIP, I left some comments inline.

Image Texture node has a Frame socket for image sequences but I'd imagine there is less need for that here.

I think a frame socket makes sense here too.

source/blender/nodes/geometry/nodes/node_geo_trace_image.cc
33–37

I don't know if this is just a WIP patch thing, but I think it's worth refactoring this a bit further. A couple options:

  • Add a separate API (I'm not exactly sure where to put it, but there are some similar simplified APIs to libraries in intern I think.
  • Further refactor this to avoid the grease pencil naming, etc.

I think the first option is probably better, though it would involve changing grease pencil code too.

124–127

Some of these macros aren't used at all. Maybe they weren't used where you copied them from either.

178–179

Maybe it would be simpler to do the scale and offset in separate passes afterwards, so they don't need to be passed around this deep.

186–196

It looks like this is just evaluating a Bezier spline. In that case, it's probably preferable to create a Bezier output directly, for more artistic control later on. Maybe I'm misinterpreting this code.

324–345

Keep these three functions at the top, like other files.

This revision now requires changes to proceed.Nov 2 2021, 5:23 AM
  • Boiler plate (provided by Hans)
  • Bez curves work
  • remove io
  • Split files and some cleaning
  • Add func comments

Thanks for picking this up again. It looks good outputting Bezier curves directly. Besides the comment inline, I don't think there's too much more to do. Since the functionality is from a library there's not too much we could do anyway. Though maybe there's an opportunity to offload some of the complexity of the scale handling to the "Scale" input and further transformations after.

source/blender/geometry/intern/trace_image.cc
86–96 ↗(On Diff #57562)

Personally I'd like to see the code style/quality pushed further here, unless there's a comment that references the place these macros came from.

These macros should become functions at least, and the ED_gpencil part of the function names should be removed.
I get the reasoning for not changing it at all, personally I don't think it's worth it though.

Hans Goudey (HooglyBoogly) requested changes to this revision.Dec 9 2022, 11:28 PM

Requesting changes based on the previous comment.

This revision now requires changes to proceed.Dec 9 2022, 11:28 PM