Curves: Add basic custom normals support #116066
No reviewers
Labels
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116066
Loading…
Reference in New Issue
No description provided.
Delete Branch "HooglyBoogly/blender:curves-normals"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add a new normal mode called "Custom" which directly interpolates
a "custom_normal" attribute to the evaluated points for the final
normal. Extend the "Set Curve Normal" node with this mode and
give it the ability to set the custom normal value.
This is intentionally a very basic implementation of custom normals.
In particular, the storage is not rotation invariant. So the normals
are expected to be set procedurally at the end of the modifier stack.
On the other hand, it is very easy to understand and explain.
Note that custom normals are not stored per Bezier handle.
This is a general problem with Blender's Bezier curve design.
@blender-bot package
Package build started. Download here when ready.
This simple approach already brings a lot of control that is currently not possible to achieve and even once a more 'smart' approach will exist that can be relative to some space per curve, this approach is still useful to override the normals in local object space.
We talked about the name of this option and changing it to something like
Free
. I'm not too opinionated on this tbh. Might be interesting to think about how other modes in the future would be called, but I think we could still change the name then to make it fit better into the context of those other modes.Generally seems ok, but I still have concerns.
Free
overCustom
as well.Transform Geometry
andRealize Instances
nodes... Setting custom normals feels much more limited if those two nodes can break them already. If we wanted to add that later, we will have to add this as an option because otherwise it would break backward compatibility. How could one keep normals intact after a realizing instances now with just this patch?CurvesGeometry::evaluated_tangents()
andCurvesGeometry::evaluated_normals()
are orthogonal. This is not the case anymore. If this is not fixed, it should at least to explicitly documented. Also I'd like to see some good use case that justifies calling those vectors "normals", instead of just using them as normal attributes. Looks like theCurve to Mesh
node is the only node using the evaluated normals as input currently. In theory we could also just expose a normal input in that node instead.Right, changed that now. The attribute is still called
custom_normal
though. Don't have a strong opinion, but I guess that represents its goal the best.Great point, added that now.
Yes, I will document this.
Unfortunately it's not that simple. Evaluating a field on control points and interpolating it to evaluated points wouldn't give the same behavior for all curve types, especially Bezier curves where the handles can't store attributes. Normals are calculated based on evaluated points positions in general too. Theoretically there could be a special case for the "Normal" input, but without a more general abstraction for operating on evaluated points with fields, I think that's just too magical.
@ -160,2 +160,4 @@
*/
Span<float> nurbs_weight;
Span<float3> custom_normal;
Could use a comment explaining why it has special handling.
@ -1359,1 +1380,4 @@
if (all_curves_info.create_custom_normal_attribute) {
if (curves_info.custom_normal.is_empty()) {
all_handle_right.slice(dst_point_range).fill(float3(0, 0, 1));
Copy paste error (
all_handle_right
).@ -1360,0 +1383,4 @@
all_handle_right.slice(dst_point_range).fill(float3(0, 0, 1));
}
else {
copy_transformed_directions(
Seems correct, but I was wondering whether this needs similar treatment as when deforming mesh normals which are multiplied with transpose of the inverse of that matrix. Maybe you can double check that: https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/geometry/transforming-normals.html
Ah, I guess I thought
transform_direction
was a solution to that, but looking into it more I'm not sure. I'll research this more.@ -23,1 +23,4 @@
b.add_input<decl::Bool>("Selection").default_value(true).hide_value().field_on_all();
if (const bNode *node = b.node_or_null()) {
if (node->custom1 == NORMAL_MODE_CUSTOM) {
b.add_input<decl::Vector>("Normal").default_value({0.0f, 0.0f, 1.0f}).field_on_all();
For this kind of socket we don't use dynamic socket declarations yet, because it's incompatible with the idea of exposing the enum as socket.
Right, good point
@ -1057,6 +1078,16 @@ static void transform_positions(MutableSpan<float3> positions, const float4x4 &m
});
}
static void transform_directions(MutableSpan<float3> directions, const float4x4 &matrix)
same as in the other transform normal function in
realize_instances.cc
.@ -293,6 +298,23 @@ static void copy_transformed_positions(const Span<float3> src,
});
}
static void copy_transformed_directions(const Span<float3> src,
copy_transformed_normals
@ -296,0 +309,4 @@
else {
threading::parallel_for(src.index_range(), 1024, [&](const IndexRange range) {
for (const int i : range) {
dst[i] = math::transform_direction(normal_transform, src[i]);
Might be reasonable to use raw matrix multiplication here, since you did the direction-specific part already above and ended up with a 3x3 matrix.