Custom normals design for curves #100859

Open
opened 2022-09-06 16:59:29 +02:00 by Hans Goudey · 14 comments
Member

Currently curve normals are calculated automatically. We have two modes, Z-Up, and "Minimum Twist".
We probably want to introduce X-Up and Y-Up too, just for consistency, but this won't give enough control in some cases still. So we still need some ability to make normals more custom.

Option 1: Custom Normals
One solution is to use a "Set Custom Normals" node. However, that requires accepting that the normals might not be orthogonal to the tangent, or making it a lossy operation.

Option 2: "up" Attribute
Another option is adding another attribute that influences the automatic calculation of normals like tilt does currently.
The up attribute would be an initial starting direction for the normal. The final normal would be the direction most aligned with the up direction that's still orthogonal to the tangent.

Currently curve normals are calculated automatically. We have two modes, Z-Up, and "Minimum Twist". We probably want to introduce X-Up and Y-Up too, just for consistency, but this won't give enough control in some cases still. So we still need some ability to make normals more custom. **Option 1: Custom Normals** One solution is to use a "Set Custom Normals" node. However, that requires accepting that the normals might not be orthogonal to the tangent, or making it a lossy operation. **Option 2: "up" Attribute** Another option is adding another attribute that influences the automatic calculation of normals like `tilt` does currently. The `up` attribute would be an initial starting direction for the normal. The final normal would be the direction most aligned with the up direction that's still orthogonal to the tangent.
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly

Added subscriber: @mod_moder

Added subscriber: @mod_moder

I think that the normal should only be set for the first point of the curve (and then auto calculation)
And also, changing the curve should automatically change the normal, but for this, the change in the curve must have a basis. Since we can't change a simple translation into a transformation with a matrix and a translation vector, it's better to give this right to the user.
That is, we recognize that the seed of the normal was set by the user. But if the curve has been changed, then the correctness of the normal is not guaranteed. The user himself must write it down the way it is in his opinion.
However, the properties of the normal (length, perpendicularity) remain the same. If the specified normal does not match this, or it did after transforming the curve, the custom normal will be changed to correct it.

I think that the normal should only be set for the first point of the curve (and then auto calculation) And also, changing the curve should automatically change the normal, but for this, the change in the curve must have a basis. Since we can't change a simple translation into a transformation with a matrix and a translation vector, it's better to give this right to the user. That is, we recognize that the seed of the normal was set by the user. But if the curve has been changed, then the correctness of the normal is not guaranteed. The user himself must write it down the way it is in his opinion. However, the properties of the normal (length, perpendicularity) remain the same. If the specified normal does not match this, or it did after transforming the curve, the custom normal will be changed to correct it.

Added subscriber: @Yuro

Added subscriber: @Yuro

Added subscriber: @hadrien

Added subscriber: @hadrien

In #100859#1413127, @mod_moder wrote:
I think that the normal should only be set for the first point of the curve (and then auto calculation)
And also, changing the curve should automatically change the normal, but for this, the change in the curve must have a basis. Since we can't change a simple translation into a transformation with a matrix and a translation vector, it's better to give this right to the user.
That is, we recognize that the seed of the normal was set by the user. But if the curve has been changed, then the correctness of the normal is not guaranteed. The user himself must write it down the way it is in his opinion.
However, the properties of the normal (length, perpendicularity) remain the same. If the specified normal does not match this, or it did after transforming the curve, the custom normal will be changed to correct it.

I think this could work best in order to achieve continuity along the curve : specify first point normal (or let Blender figure it out using the up attribute), then compute the rest through parallel transport or some other technique.

> In #100859#1413127, @mod_moder wrote: > I think that the normal should only be set for the first point of the curve (and then auto calculation) > And also, changing the curve should automatically change the normal, but for this, the change in the curve must have a basis. Since we can't change a simple translation into a transformation with a matrix and a translation vector, it's better to give this right to the user. > That is, we recognize that the seed of the normal was set by the user. But if the curve has been changed, then the correctness of the normal is not guaranteed. The user himself must write it down the way it is in his opinion. > However, the properties of the normal (length, perpendicularity) remain the same. If the specified normal does not match this, or it did after transforming the curve, the custom normal will be changed to correct it. I think this could work best in order to achieve continuity along the curve : specify first point normal (or let Blender figure it out using the up attribute), then compute the rest through parallel transport or some other technique.
Author
Member

Ah, I forgot to mention that the up attribute could be added to the point of curve attribute domain. If it was on the curve domain it would work like you suggested.
This behavior could also be achieved with a more explicit "Set Custom Normals" node, or maybe even something more general.

Ah, I forgot to mention that the up attribute could be added to the point of curve attribute domain. If it was on the curve domain it would work like you suggested. This behavior could also be achieved with a more explicit "Set Custom Normals" node, or maybe even something more general.

Added subscriber: @mont29

Added subscriber: @mont29

I think a custom normal is different than that 'up' attribute? The former would indeed allow non-orthogonal normals, just like it does with meshes. The later is only a way to choose a direction on the normal plane of the curve, which would still always produce a 'real' orthogonal normal.

So I think option 2 would make more sense for now, not even sure if option 1 would have practical usages with curves actually? Might be missing some important points here though.

I think a custom normal is different than that 'up' attribute? The former would indeed allow non-orthogonal normals, just like it does with meshes. The later is only a way to choose a direction on the normal plane of the curve, which would still always produce a 'real' orthogonal normal. So I think option 2 would make more sense for now, not even sure if option 1 would have practical usages with curves actually? Might be missing some important points here though.

Added subscriber: @GeorgiaPacific

Added subscriber: @GeorgiaPacific

Added subscriber: @LuisPereira

Added subscriber: @LuisPereira

Hi!
I'm new here but I'm very interested in this design task. In fact, I've more or less built my own custom node group (in current Blender) that achieves something very similar to the design goal (I'm attaching a blend file with that node group). So hopefully my thoughts will be of some use (apologies for the lengthy post... I've spent quite a bit of time thinking about this).

An application:
The main application I have in mind is something like the image below (which is from the blend file I attached at the end), where we wrap strips of fabric/bandages around a character's body.
bandages_on_arm.png

Overview of the geo nodes in the application:
If you enlarge the picture, you should be able to see the curve from which the bandages are generated using geo nodes. The geo nodes are doing 3 things here:

  1. slightly shrinkwrapping the curve around the arm (though it started pretty close);
  2. (the main part) adjusting the curve's tilt (using Set Curve Tilt Node and plenty of math) so the curve's normals point in about the same direction as the mesh normals (transferred to the curve from the mesh). Naturally, the mesh's normals might not be precisely perpendicular to the curve's tangents (although the shrinkwrapping ensures they'll be close to perpendicular), and I address this as suggested in option 2, by projecting the mesh's normals onto the planes perpendicular to the respective tangents, then renormalizing;
  3. extruding the curve.

A key difficulty
In effect, my node group is more or less achieving option 2 via the Set Curve Tilt Node, though this required a lot of care and some frustrating mistakes. At first sight, one might think that building this node group is just a matter of determining the angles between the current normals and the intended normals (which is just a bunch of linear algebra plus trigonometry), then setting that as the tilt (while using the tangent to decide if the tilt is positive or negative).
However... the naive procedure above will invariably lead to examples as below, where the curve does a 360 degree flip over a short segment.
bandages_on_arm_twisted.png
Fixing these 360 flips was a huge pain, since normally (i.e. while coding) it would require using a for loop to iterate over the curve's points, which geo nodes don't really allow... I eventually got around this by using the accumulate node to implement the for loop in a non obvious way, though I can't say I recommend that workflow to anyone...

Which leads me to a key remark: my node group using Set Curve Tilt assumes that the original curve was using "Minimum Twist".
Or to be more specific, had the curve started as Z-up then I believe my node group would still produce 360 flips on occasion, due to the fact that the "rest position" (i.e. zero Tilt) in the Z-up mode includes some twisting, which my node group does not account for.

A limitation
My node group has one limitation when compared to a true implementation of option 2.
When the curve is a loop, my node group can only produce strips that are obtained by twisting a cylindrical strip (on the left below). This excludes surfaces like the Moebius strip on the center (generated by a loop with a "total tilt" of 180 degrees) or the "double Moebius strip" on the right (generated by a loop with a "total tilt" of 360 degrees).

I think neither the Moebius strip nor the double Moebius strip can currently be generated by Blender by extruding curves.
And while generating the Moebius strip is out of the question (since it doesn't have a well defined normal), I believe that a full implementation of option 2 would allow for generating a double Moebius strip.

moebius.png

AlignNormalsExample.blend

Hi! I'm new here but I'm very interested in this design task. In fact, I've more or less built my own custom node group (in current Blender) that achieves something very similar to the design goal (I'm attaching a blend file with that node group). So hopefully my thoughts will be of some use (apologies for the lengthy post... I've spent quite a bit of time thinking about this). **An application:** The main application I have in mind is something like the image below (which is from the blend file I attached at the end), where we wrap strips of fabric/bandages around a character's body. ![bandages_on_arm.png](https://archive.blender.org/developer/F13478009/bandages_on_arm.png) **Overview of the geo nodes in the application:** If you enlarge the picture, you should be able to see the curve from which the bandages are generated using geo nodes. The geo nodes are doing 3 things here: 1) slightly shrinkwrapping the curve around the arm (though it started pretty close); 2) (**the main part**) adjusting the curve's tilt (using Set Curve Tilt Node and plenty of math) so the curve's normals point in about the same direction as the mesh normals (transferred to the curve from the mesh). Naturally, the mesh's normals might not be precisely perpendicular to the curve's tangents (although the shrinkwrapping ensures they'll be close to perpendicular), and I address this as suggested in option 2, by projecting the mesh's normals onto the planes perpendicular to the respective tangents, then renormalizing; 3) extruding the curve. **A key difficulty** In effect, my node group is more or less achieving option 2 via the Set Curve Tilt Node, though this required a lot of care and some frustrating mistakes. At first sight, one might think that building this node group is just a matter of determining the angles between the current normals and the intended normals (which is just a bunch of linear algebra plus trigonometry), then setting that as the tilt (while using the tangent to decide if the tilt is positive or negative). However... the naive procedure above will invariably lead to examples as below, where the curve does a 360 degree flip over a short segment. ![bandages_on_arm_twisted.png](https://archive.blender.org/developer/F13478092/bandages_on_arm_twisted.png) Fixing these 360 flips was a huge pain, since normally (i.e. while coding) it would require using a for loop to iterate over the curve's points, which geo nodes don't really allow... I eventually got around this by using the accumulate node to implement the for loop in a non obvious way, though I can't say I recommend that workflow to anyone... Which leads me to a key remark: **my node group using Set Curve Tilt assumes that the original curve was using "Minimum Twist"**. Or to be more specific, had the curve started as Z-up then I believe my node group would still produce 360 flips on occasion, due to the fact that the "rest position" (i.e. zero Tilt) in the Z-up mode includes some twisting, which my node group does not account for. **A limitation** My node group has one limitation when compared to a true implementation of option 2. When the curve is a loop, my node group can only produce strips that are obtained by twisting a cylindrical strip (on the left below). This excludes surfaces like the Moebius strip on the center (generated by a loop with a "total tilt" of 180 degrees) or the "double Moebius strip" on the right (generated by a loop with a "total tilt" of 360 degrees). I think neither the Moebius strip nor the double Moebius strip can currently be generated by Blender by extruding curves. And while generating the Moebius strip is out of the question (since it doesn't have a well defined normal), I believe that a full implementation of option 2 would allow for generating a double Moebius strip. ![moebius.png](https://archive.blender.org/developer/F13478145/moebius.png) [AlignNormalsExample.blend](https://archive.blender.org/developer/F13478011/AlignNormalsExample.blend)
Member

Added subscriber: @CharlieJolly

Added subscriber: @CharlieJolly
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
8 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#100859
No description provided.