Fix #120761: Tag all PBVH nodes for needing a visibility update when using hide tools #120798

Open
Sean Kim wants to merge 1 commits from Sean-Kim/blender:fix-120761 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This PR changes behavior in the Sculpt mode Hide Gesture tools to always tag every PBVH node for a visibility update to avoid faces not updating when they are on the boundary of different nodes.

Alternate Approaches

  • A smarter approach could be done by comparing the bounds of each PBVH and only tagging adjacent nodes, however the added complexity does not seem worth it over the current implementation.
This PR changes behavior in the Sculpt mode Hide Gesture tools to always tag every PBVH node for a visibility update to avoid faces not updating when they are on the boundary of different nodes. ## Alternate Approaches * A smarter approach could be done by comparing the bounds of each PBVH and only tagging adjacent nodes, however the added complexity does not seem worth it over the current implementation.
Sean Kim added 1 commit 2024-04-18 23:22:41 +02:00
Sean Kim requested review from Hans Goudey 2024-04-18 23:23:23 +02:00
Member

I think this is actually an important optimization. Changing visibility should feel very snappy, even with meshes that have millions of faces. This requires rebuilding the GPU buffers for every single PBVH node. For reference, the change was made in 4e66769ec0, and a significant part of the performance improvement comes from not rebuilding the GPU buffers.

It's not just that this optimization in particularly is that important though, but I think it helps us to learn about how to do these operations in a non-global way. Some ideas:

  1. Change hide update functions to work on faces rather than vertices (like the existing face_hide_update)
  2. Handle vert to face visibility flushing ourselves in a separate loop of affected nodes. Also tag any nodes changed there.
  3. Calculate new hide values into a newly allocated mesh-sized array, test differences on the node level afterwards
  4. Do calculation for non-unique verts in existing loop, just to check if there are changes.

Testing which of those is fastest for cases like hiding a small portion of a 16 million vertex mesh might be fun. I can take this over though if it sounds like too much.

I think this is actually an important optimization. Changing visibility should feel very snappy, even with meshes that have millions of faces. This requires rebuilding the GPU buffers for every single PBVH node. For reference, the change was made in 4e66769ec09461384af48b0bfdafc28884f01d19, and a significant part of the performance improvement comes from not rebuilding the GPU buffers. It's not just that this optimization in particularly is _that_ important though, but I think it helps us to learn about how to do these operations in a non-global way. Some ideas: 1. Change hide update functions to work on faces rather than vertices (like the existing `face_hide_update`) 2. Handle vert to face visibility flushing ourselves in a separate loop of affected nodes. Also tag any nodes changed there. 3. Calculate new hide values into a newly allocated mesh-sized array, test differences on the node level afterwards 4. Do calculation for non-unique verts in existing loop, just to check if there are changes. Testing which of those is fastest for cases like hiding a small portion of a 16 million vertex mesh might be fun. I can take this over though if it sounds like too much.
Author
Member

Thanks for the further context on the GPU side of things. I wasn't aware of the follow up changes that this would cause - I can try tackling & thinking about the different approaches.

In general, one of the things about this area of code that I'd like to try and minimize is needing to remember to tag the PBVH node for visibility updates in the higher level operator code since that seems like an area that can easily have regressions. This makes me not inclined to explore 2. in a lot of depth as I feel like that goes in the opposite direction, but I'd be interested in hearing your thoughts on this too.

Edit: Didn't mean to link to that random issue.

Thanks for the further context on the GPU side of things. I wasn't aware of the follow up changes that this would cause - I can try tackling & thinking about the different approaches. In general, one of the things about this area of code that I'd like to try and minimize is needing to remember to tag the PBVH node for visibility updates in the higher level operator code since that seems like an area that can easily have regressions. This makes me not inclined to explore 2. in a lot of depth as I feel like that goes in the opposite direction, but I'd be interested in hearing your thoughts on this too. Edit: Didn't mean to link to that random issue.
Member

In general, one of the things about this area of code that I'd like to try and minimize is needing to remember to tag the PBVH node for visibility updates in the higher level operator code since that seems like an area that can easily have regressions. This makes me not inclined to explore 2. in a lot of depth as I feel like that goes in the opposite direction, but I'd be interested in hearing your thoughts on this too.

I agree with not requiring visibility updates outside of vert_hide_update. But I don't think option 2 requires that. vert_hide_update would just contain a second loop over nodes and would run the vertex -> face visibility propagation there, tagging the node if any hide_poly value changed.

>In general, one of the things about this area of code that I'd like to try and minimize is needing to remember to tag the PBVH node for visibility updates in the higher level operator code since that seems like an area that can easily have regressions. This makes me not inclined to explore 2. in a lot of depth as I feel like that goes in the opposite direction, but I'd be interested in hearing your thoughts on this too. I agree with not requiring visibility updates outside of `vert_hide_update`. But I don't think option 2 requires that. `vert_hide_update` would just contain a second loop over nodes and would run the vertex -> face visibility propagation there, tagging the node if any `hide_poly` value changed.
Author
Member

I agree with not requiring visibility updates outside of vert_hide_update. But I don't think option 2 requires that. vert_hide_update would just contain a second loop over nodes and would run the vertex -> face visibility propagation there, tagging the node if any hide_poly value changed.

I should have explained my reasoning a bit further - my thoughts were a bit incomplete when I made that comment. I believe that duplicating / mirroring logic that exists inside the bke::mesh_hide_vert_flush function into vert_hide_update seems like an unnecessary amount of overlap in functionality.

> I agree with not requiring visibility updates outside of `vert_hide_update`. But I don't think option 2 requires that. `vert_hide_update` would just contain a second loop over nodes and would run the vertex -> face visibility propagation there, tagging the node if any `hide_poly` value changed. I should have explained my reasoning a bit further - my thoughts were a bit incomplete when I made that comment. I believe that duplicating / mirroring logic that exists inside the `bke::mesh_hide_vert_flush` function into `vert_hide_update` seems like an unnecessary amount of overlap in functionality.
This pull request has changes conflicting with the target branch.
  • source/blender/editors/sculpt_paint/paint_hide.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fix-120761:Sean-Kim-fix-120761
git checkout Sean-Kim-fix-120761
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#120798
No description provided.