Fix #116418: Stroke direction wrong on curved surfaces #116539
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#116539
Loading…
Reference in New Issue
No description provided.
Delete Branch "Marcelo-Mutzbauer/blender:fix_curved_rake"
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?
Even though the brush rotation is computed as a 2D angle (based on the mouse movement), it currently gets applied by rotating the projected X direction around the the normal in 3D.
This patch ensures that rotation gets applied first, and only then does the motion direction get projected into the tangent plane.
A potential issue with the current approach is that the random perturbations will also be applied in 2D, but this seems to be fine from discussions with @JulienKaspar and @Sergey.
Also, there was an error where the location should probably be converted to world coordinates...
All these changes seem to fix the issue described in #116418.
I also noticed some minor "inconsistencies" with how the rotation is applied: For curve strokes, the direction of the curve corresponded to the upward direction of the brush. For view plane, area plane mapping and anchored strokes, the mouse motion indicated the downward direction of the brush. For compatibility, I tried my best to enforce the latter conventions throughout, but I'm not so confident about oversights.
Also, it seems like rake is being applied indiscriminately for textured brushes, regardless of whether the option is checked in the tool panel. This might have been introduced with commit
35071af
(see the changes topaint_rake_rotation_active
), but since unwinding the commit history that far breaks dependencies, I could not verify if this is the actual culprit. I did not make any changes to address this (separate) issue.Fix #116418to Fix #116418: Stroke direction wrong on curved surfaces@ -1357,3 +1357,3 @@
/* Limit how often we update the angle to prevent jitter. */
if (len_squared_v2(dpos) >= r * r) {
rotation = atan2f(dpos[0], dpos[1]);
rotation = atan2f(dpos[1], dpos[0]);
Confusingly,
atan2f
takes y(rise) as its first argument, https://en.cppreference.com/w/c/numeric/math/atan2I changed this calculation because it looks unintentional to me, but I can update the pull request to use the original way of measuring that angle.
On the other hand, changing conventions now is probably dangerous ...
It fixes the issue as far as I tested. So on the user side this looks good to me :1
Waiting for another dev to take a look at this.
@JulienKaspar How about the part about the random perturbations applied in 2D? Does this behave good for you?
On a code side it seems fine, so I think it is more of agreeing on the functional level, updating the commit message to it (instead of leaving note that feedback is still needed) and committing the fix.
@Marcelo-Mutzbauer I think for this I need a test case. I can't tell if it behaves wrong or correct since it's random.
Do you mean the Random Mapping or Random option for the texture rotation?
I can confirm this for Paint brushes. This seems to be because the tip shape can be set to be square, and in that case is using Rake for the stroke direction.
Unfortunately the texture is then automatically also using Rake ... that shouldn't be the case.
Maybe we can fix that separately.
Thank you all for taking a look!
The last version broke view plane mapping and some other things, hopefully that is now working again.
(
It seems like in main, the
ups->rotation
was supposed to represent the negation of the angle of 2D rotation, which might have been motivated by the fact that when sampling the brush texture, we need the inverse transform. The latest update makes it so that it just represents the 2D angle of the brush transform (even though I am second-guessing this maneuver now). It does not represent the rotation of the mouse movement anymore as it did in my first attempt.I noticed some minor "inconsistencies" with how the rotation is applied: For curve strokes, the direction of the curve corresponded to the upward direction of the brush. For view plane, area plane mapping and anchored strokes, the mouse motion indicated the downward direction of the brush. For compatibility, I tried my best to enforce the latter conventions throughout, but I'm not so confident about oversights.
)
@JulienKaspar I was thinking of the Random option for texture rotation... For area plane mapping, there are two possible approaches here: (1) Either we randomly rotate the brush around the axis that points out of the monitor, or (2) we rotate it around the normal under the cursor. The patch currently implements approach (1). However, this only concerns the general direction of the brush texture, since we would still apply the brush using area plane mapping.
I am having a hard time coming up with a test case, but the difference mainly comes to bear when sculpting on parts of the mesh that are being looked at from a slanted direction (say the outer rim of the sphere).
I guess we could also expose it as an option, but we've got enough of those as things stand ...
@Marcelo-Mutzbauer In that case I think it's fine. SInce it's a random angle for each step of the stroke and it doesn't cause any issues with the texture mapping itself, it works well 👍
I never noticed the inverted texture rotation for Curve Strokes. Good catch!
I'd say on my end this PR is ready to go into main.
As suggested by @Sergey, I tried to update the PR description to remove the part about feedback.
@Marcelo-Mutzbauer hi, no performance regressions with those changes?
@ThinkingPolygons hi, I don't think there should be, but admittedly I did not do any meticulous benchmarking ... Did you notice something?
Basically all the major changes only affect areas that don't seem like hotpaths (in that they don't run per-vertex or anything like that), and the new computations shouldn't be significantly slower.
I didn't notice any performance regressions. I'll update my review as approved.
On the code side seems fine, the correctness of behavior I'd rely on Julien's testing.
Good work in catching inconsistencies and documenting the semantic of the brush rotation.