Page MenuHome

Curves: Deform curves based on surface node.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on May 5 2022, 5:01 PM.
Tags
None
Tokens
"Like" token, awarded by duarteframos."Love" token, awarded by jmztn."Love" token, awarded by HEYPictures."Like" token, awarded by Moder."Love" token, awarded by brecht."Love" token, awarded by GeorgiaPacific."Love" token, awarded by Bit."Love" token, awarded by filedescriptor.

Details

Summary

For the purpose of getting this done for Blender 3.3 we are making a trade-off. Instead of having general curve deformation nodes, we have one node that just deforms the curves based on the surface object set in the properties editor. We intentionally don't expose inputs in the node, to make future versioning simpler. We do want to support generating hair and the surface in geometry nodes in the future, but not as part of this patch. This patch is concerned with making the common use case of having hair on some other mesh object work.

This patch adds the following things:

  • A new Deform Curves on Surface node, which deforms curves with attachment information based on the surface object and uv map set in the properties panel.
  • A new Add Rest Position checkbox in the shape keys panel.
  • The Add > Curve > Empty Hair operator now sets up a simple geometry nodes setup that deforms the hair based on the surface. It also makes sure that the rest position attribute is added to the surface.
  • A new Object (Attach Curves to Surface) operator is added to the Set Parent To (ctrl+P) menu, to attach existing curves to a new surface.

Notes:

  • There is still a discontinuity between faces when faces are rotated (although that seems to exist in the old hair system as well). See todo comment in code.
  • Crazy-space will be implemented separately.

Diff Detail

Repository
rB Blender
Branch
deform-curves-with-surface (branched from master)
Build Status
Buildable 21988
Build 21988: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.May 5 2022, 5:01 PM
Jacques Lucke (JacquesLucke) created this revision.
  • Merge branch 'master' into deform-curves-with-surface

Curves: Support surface deformation (WIP).

I really like this implementation. It is so much better than the old one (in workflow terms)
Some thoughts

  • How does it propagate when sculpting the mesh with multires? or editing in Edit Mode?
  • What happens if there are overlapping UVs (even from modifiers like arrey, etc.)? Does it duplicates/averages/instances the curves count?
  • What happens if a single curve is generated exactly on a vertex which has multiple UV coordinates? (Might be more relevant while distributing hair procedurally.)
  • Can you choose from which UV you want the curves to gain their attachment-UV-coords field? How easy is it to change it later on? (actually, I think it can be done later on with a simple operation)
  • Now that UV has become a first-class citizen in geometry node, I think it crucial to add support for UDIMs in geo-node(And not because I need it for my current project ;))
  • For example, currently, you can distribute the hair using a multi-tiles UV, but you can't use a custom texture to influence any of it parameters.

Update the algorithm that computes the deformation.

Keeping @Brecht Van Lommel (brecht) in the loop (not from the code point of view, but mostly because I talked about this patch with him, and he had some concerns about subdivision support which seems to be addressed).

@Jacques Lucke (JacquesLucke) for the final commit I think it is important to mention the implication of subsurf modifiers, how they will be always calculated on the CPU if needed for the surface. It is something we will need to add to the manual as well.

Note: I haven't tested the patch yet.

  • Merge branch 'master' into temp-deform-curves-with-surface
  • store rest position
  • set parent when adding hair
  • don't take 3d cursor position into account
  • add deformation node tree
  • Merge branch 'master' into temp-deform-curves-with-surface
  • Remove Surface input from node, take information from self-object.
  • Add Rest Position checkbox in Shape Keys panel. Kind of makes sense because the rest position attribute is created before shape keys are evaluated.
  • Started implementing a new option for parenting (ctrl+P). That's supposed to be the main way to change the surface. It's not quite working yet unfortunately, sometimes the curves still move to the wrong place after parenting.

  • Merge branch 'master' into temp-deform-curves-with-surface
  • fix adding deform node tree twice
  • take object transforms into account in deformation node
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  • Merge branch 'master' into temp-deform-curves-with-surface
  • rename the operator in the parent menu
  • Merge branch 'master' into temp-deform-curves-with-surface

Suggestion (based on conversation on blender.chat)

  • Call the node "Deform Curves on Surface"
  • Call the initial modifier "SurfaceDeform" (and the geometry-nodes "Surface Deform"
  • The "Object (Attach Curves to Surface)" name is good

I put some updates to this patch in the public branch temp-deform-curves-on-surface.

  • Threadsafe access to face corner normals
  • Reword the UV sampling error message and include the number of invalid coordinates
  • Update naming of node and modifier
  • A commit I discuss below

I don't think there's much left to do for this patch, but I'll wait to accept it until tomorrow.


I'm finding that the results are different when the surface object is in edit mode. I think that's a bug and not expected, since the original and evaluated meshes should be the same either way.
I don't really know what's going on here though.

Object ModeEdit Mode

Maybe this is related, but I would expect some change like this to be necessary, otherwise the node doesn't have the actual original mesh data: rBb39cd9a84905: Test: Retrieve original mesh information from the editmesh what do you think? Doesn't seem to fix the problem I was seeing above though.

source/blender/editors/curves/intern/curves_add.cc
70 ↗(On Diff #53346)

Do you think we want to search for an existing node group before adding a new one, in case someone has many hair objects?

I guess that could be left until later if it's necessary.

source/blender/editors/curves/intern/curves_ops.cc
1006 ↗(On Diff #53346)

Best to ask Bastien about this before committing I think

1031 ↗(On Diff #53346)

I'd add and set it as the parent at the end here

source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc
32

Not an important thing, just curious-- I've been keeping the bke:: prefix on CurvesGeometry since it's short and gives a bit of context. Do you have an opinion?

166

Can we be sure about this orthonormality for zero-area triangles? I think not? But maybe that's fine because everything would be broken anyway.

177–180

I'm finding it a bit hard to understand the need to subtract and add pos_old before and afterwards, I would think the rotation would apply directly to the translation. Is it clear what I'm missing?

It's a bit harder because the syntax is a bit worse than the rest of the function.
I think it would be worth it to find some better way to write this sort of thing.

Bastien Montagne (mont29) added inline comments.
source/blender/editors/curves/intern/curves_ops.cc
1006 ↗(On Diff #53346)

Looking at curves_foreach_id, curves->surfaces is processed with IDWALK_CB_NOP, meaning it is not refcounting currently. So no, no usercount increment here.

Jacques Lucke (JacquesLucke) marked 5 inline comments as done.Jul 8 2022, 10:52 AM

I'm finding that the results are different when the surface object is in edit mode. I think that's a bug and not expected, since the original and evaluated meshes should be the same either way.

Not exactly sure what is happening. Can be investigated in master.

source/blender/editors/curves/intern/curves_add.cc
70 ↗(On Diff #53346)

yeah, let's not make this more complex for now

source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc
32

Think that makes sense when both types are used in a function, otherwise not so much.

177–180

Added a comment. The subtract and add moves the rotation origin to the position on the surface. The translation is independent of the rotation.

Jacques Lucke (JacquesLucke) marked 2 inline comments as done.
  • Merge branch 'master' into temp-deform-curves-with-surface
  • Changes from Hans
  • cleanup
Jacques Lucke (JacquesLucke) retitled this revision from Curves: Deform curves based on surface node. (WIP) to Curves: Deform curves based on surface node..Jul 8 2022, 10:53 AM
Jacques Lucke (JacquesLucke) edited the summary of this revision. (Show Details)
  1. Suggestion for the error message: "Invalid surface attachment UVs on 15 curves".
  2. Need to redraw/update the properties editor when running Snap to Nearest Surface (so the error goes away).

PS: I think the edit/object mode scenario Hans described is not a bug, but it is working as expected.

  • apply P3060
  • Merge branch 'master' into temp-deform-curves-with-surface
This revision is now accepted and ready to land.Jul 8 2022, 2:18 PM