Fix #107123: Refactor sculpt normal calculation to require vert poly map #107458

Merged
Joseph Eagar merged 6 commits from HooglyBoogly/blender:pbvh-faces-normals-fix-alternate into main 2023-05-09 22:36:37 +02:00
Member

Change PBVH normal calculation to also update vertices connected to
vertices with an update tag. This is necessary because vertex normals
are the mixed face normals, so changing any face's normal will change
the normals of all connected faces.

This change requires that the PBVH always have a vertex to face
topology map available. In the future this will likely be cached on
meshes though, which will reduce the delay it adds when entering sculpt
mode.

Now, first all face normals are updated, then the normals for
connected vertices are mixed from the face normals. This is a
significant simplification to the whole process, which previously
worked with atomics and normals at the triangle level. Similar changes
changes for regular non-sculpt normal calculation are being worked on
in #105920.

Change PBVH normal calculation to also update vertices connected to vertices with an update tag. This is necessary because vertex normals are the mixed face normals, so changing any face's normal will change the normals of all connected faces. This change requires that the PBVH always have a vertex to face topology map available. In the future this will likely be cached on meshes though, which will reduce the delay it adds when entering sculpt mode. Now, first all face normals are updated, then the normals for connected vertices are mixed from the face normals. This is a significant simplification to the whole process, which previously worked with atomics and normals at the triangle level. Similar changes changes for regular non-sculpt normal calculation are being worked on in #105920.
Hans Goudey added 1 commit 2023-04-29 06:16:54 +02:00
Hans Goudey added this to the Sculpt, Paint & Texture project 2023-04-29 06:17:01 +02:00
Joseph Eagar requested changes 2023-04-29 23:21:28 +02:00
@ -1461,3 +1419,2 @@
for (int i = 0; i < totvert; i++) {
const int v = verts[i];
threading::parallel_for(positions.index_range(), 1024, [&](const IndexRange range) {
Member

We can't afford to iterate over all the verts of the mesh here. It's better to build a list of verts to update from the PBVH nodes.

We can't afford to iterate over all the verts of the mesh here. It's better to build a list of verts to update from the PBVH nodes.
Member

The list doesn't have to be unique btw, there's no point going through the effort to eliminate duplicates.

The list doesn't have to be unique btw, there's no point going through the effort to eliminate duplicates.
Author
Member

Well, since a face usually has four corners, not de-duplicating will mean we have to do 4x the calculations, for both vertices and faces. I didn't benchmark it yet, but I'll bet using VectorSet to de-duplicate is worth it here.

Well, since a face usually has four corners, not de-duplicating will mean we have to do 4x the calculations, for both vertices and faces. I didn't benchmark it yet, but I'll bet using `VectorSet` to de-duplicate is worth it here.
Member

Hrm, you might be right.

Hrm, you might be right.
Hans Goudey added 2 commits 2023-04-30 22:06:31 +02:00
Hans Goudey requested review from Joseph Eagar 2023-04-30 22:13:03 +02:00
Julien Kaspar added the
Module
Sculpt, Paint & Texture
label 2023-05-01 10:42:21 +02:00
Joseph Eagar requested changes 2023-05-01 22:19:16 +02:00
@ -1464,0 +1422,4 @@
}
},
[&]() {
update_tags.fill(false);
Member

Use verts_to_update or the node unique verts to clear the update tags.

Use `verts_to_update` or the node unique verts to clear the update tags.
Hans Goudey added 2 commits 2023-05-01 22:31:31 +02:00
Hans Goudey requested review from Joseph Eagar 2023-05-01 22:31:42 +02:00
Hans Goudey added 1 commit 2023-05-09 01:54:40 +02:00
Joseph Eagar merged commit ac02f94caf into main 2023-05-09 22:36:37 +02:00
Julien Kaspar removed this from the Sculpt, Paint & Texture project 2023-05-15 17:23:05 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:41 +02:00
Sign in to join this conversation.
No reviewers
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
2 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#107458
No description provided.