Sculpt geometry representation design #85296

Open
opened 2021-02-01 23:13:18 +01:00 by Pablo Dobarro · 1 comment
Member

This task goal is to discuss the requirements and design a new mesh representation structure to replace both ##Mesh## and grids in Sculpt Mode, trying to improve performances, memory usage and tool compatibility.

Requirements

Tools

Main topology queries

Almost all tools and functionality in sculpt mode relies on the following topology info:

tp1.png

Vertex to connected vertices: All cloth sculpting, boundary, pose, all smooth algorithms, data slide and flood fill operations rely on looping over neighbor vertices. This is the most performance-critical operation.

Vertex to faces that use that vertex: Used for all face set related functionality (mesh visibility state, face set boundaries, automasking, pose brush origin detection...)

On top of this, tools need to always know if a vertex is part of a mesh boundary. Right now, this is cached into a bitmap by looping over polys and edges of ##Mesh##. This info does not change during the sculpting session unless the geometry is modified.

Normal updates for deformation

Updating the normals is currently done in two loops. First normals are calculated per face and then accumulated into vertices using atomics. Then vertex normals are normalized in a second loop.

tp6.png

As a proposal, if the neighbors vertex list is stored in radial order, it is possible to approximate the normal in a single loop per vertex, without atomics and with a single square root operation. Storing the list in radial order will also help to simplify and implementing new tools.

Draw Face Sets / Face Set Gestures

tp2.png

Face to vertices that use that face: This is used in the Draw Face Sets brush to increase the precision of the falloff. As the main iterator loops over vertices, the shown topology queries are used to get the center of the affected faces and apply the brush falloff in that point instead of using the vertex directly. This also allows to paint individual faces with a Face Set

Expand / Face Set Grow / Shrink

tp3.png

Face to neighbor faces by and edge and neighbor faces by a vertex: This is used to grow/shrink face sets IDs and create different patterns in Expand. It is also used to delete Face sets from the mesh with content-aware filling.

Face Sets Init

tp5.png

Face to neighbor faces with reference to edge: This is used to create Face Sets by UV seams or crease data. The reference to the edge is needed to check different flags and limit the flood fill operation which works using faces and faces neighbors. This is currently implemented using ##BMesh##

Mesh Fairing

Fairing supports multiple algorithms to calculate vertex and loop weights to achieve different effects. The only one of those algorithms that is currently being used for the sculpt mode tools is Voronoi vertex weights.

tp10.png

When using ##Mesh##, this algorithm is using a vertex to loop map. From that loop, it needs the next and previous vertex to make a triangle. If neighbors are stored in radial order, this should be possible to implement using only that information.

Even if fairing uses loop weights, both fairing operations that are required for sculpt mode use uniform loop weights (all loops have the weight of 1), so face corner references are not needed.

Geodesic Distances

Geodesic distances is used for surface falloff and expand. The current geodesic distances algorithm needs two extra maps on top of #Mesh# to implement the following queries:

tp9.png

Edge to neighbor vertices connected by a face: Currently implemented by using and edge to poly map and then looping overt the loops of that poly.

tp7.png

Vertex to edges that use that vertex: Currently implemented with a vertex -> edge map

Geodesic distances requires references to the geometry edges.

Rendering

BVH building and ray intersections

Both are done using a separate array to store the triangles. In Multires, they use the grids directly.

Mesh / BMesh conversions

  • Sculpting with modifiers enabled require copying the coordinate data from the sculpt geometry to ##Mesh## after each deformation.(I don't think this would be problem).
  • Both remeshers require a conversion from the sculpt geometry to ##Mesh## in order to work. Voxel should be expected to work with high poly meshes, and it already contains a ##Mesh## -> ##BMesh## -> ##Mesh## conversion which takes up to 80% of its execution time.
  • Trimming tools require a conversion to ##BMesh## in order to use the boolean solver.
  • Mesh slicing and extracting require the sculpt geometry with mask and face set datalayers as ##Mesh##
  • Face sets form Edit mode selection requires ##Mesh## selection flags. This can be copied on geometry creation as they are not modified by sculpt mode.
  • Dyntopo needs to be discussed separately. There should not be a problem to use ##BMesh## for it.
This task goal is to discuss the requirements and design a new mesh representation structure to replace both ##Mesh## and grids in Sculpt Mode, trying to improve performances, memory usage and tool compatibility. # Requirements ## Tools ### Main topology queries Almost all tools and functionality in sculpt mode relies on the following topology info: ![tp1.png](https://archive.blender.org/developer/F9608160/tp1.png) **Vertex to connected vertices:** All cloth sculpting, boundary, pose, all smooth algorithms, data slide and flood fill operations rely on looping over neighbor vertices. This is the most performance-critical operation. **Vertex to faces that use that vertex:** Used for all face set related functionality (mesh visibility state, face set boundaries, automasking, pose brush origin detection...) On top of this, tools need to always know if a vertex is part of a mesh boundary. Right now, this is cached into a bitmap by looping over polys and edges of ##Mesh##. This info does not change during the sculpting session unless the geometry is modified. ### Normal updates for deformation Updating the normals is currently done in two loops. First normals are calculated per face and then accumulated into vertices using atomics. Then vertex normals are normalized in a second loop. ![tp6.png](https://archive.blender.org/developer/F9608162/tp6.png) As a proposal, if the neighbors vertex list is stored in radial order, it is possible to approximate the normal in a single loop per vertex, without atomics and with a single square root operation. Storing the list in radial order will also help to simplify and implementing new tools. ### Draw Face Sets / Face Set Gestures ![tp2.png](https://archive.blender.org/developer/F9608164/tp2.png) **Face to vertices that use that face:** This is used in the Draw Face Sets brush to increase the precision of the falloff. As the main iterator loops over vertices, the shown topology queries are used to get the center of the affected faces and apply the brush falloff in that point instead of using the vertex directly. This also allows to paint individual faces with a Face Set ### Expand / Face Set Grow / Shrink ![tp3.png](https://archive.blender.org/developer/F9608166/tp3.png) **Face to neighbor faces by and edge and neighbor faces by a vertex:** This is used to grow/shrink face sets IDs and create different patterns in Expand. It is also used to delete Face sets from the mesh with content-aware filling. ### Face Sets Init ![tp5.png](https://archive.blender.org/developer/F9608168/tp5.png) **Face to neighbor faces with reference to edge**: This is used to create Face Sets by UV seams or crease data. The reference to the edge is needed to check different flags and limit the flood fill operation which works using faces and faces neighbors. This is currently implemented using ##BMesh## ### Mesh Fairing Fairing supports multiple algorithms to calculate vertex and loop weights to achieve different effects. The only one of those algorithms that is currently being used for the sculpt mode tools is Voronoi vertex weights. ![tp10.png](https://archive.blender.org/developer/F9608170/tp10.png) When using ##Mesh##, this algorithm is using a vertex to loop map. From that loop, it needs the next and previous vertex to make a triangle. If neighbors are stored in radial order, this should be possible to implement using only that information. Even if fairing uses loop weights, both fairing operations that are required for sculpt mode use uniform loop weights (all loops have the weight of 1), so face corner references are not needed. ### Geodesic Distances Geodesic distances is used for surface falloff and expand. The current geodesic distances algorithm needs two extra maps on top of #Mesh# to implement the following queries: ![tp9.png](https://archive.blender.org/developer/F9608172/tp9.png) **Edge to neighbor vertices connected by a face:** Currently implemented by using and edge to poly map and then looping overt the loops of that poly. ![tp7.png](https://archive.blender.org/developer/F9608176/tp7.png) **Vertex to edges that use that vertex**: Currently implemented with a vertex -> edge map **Geodesic distances requires references to the geometry edges.** ## Rendering ## BVH building and ray intersections Both are done using a separate array to store the triangles. In Multires, they use the grids directly. ## Mesh / BMesh conversions * Sculpting with modifiers enabled require copying the coordinate data from the sculpt geometry to ##Mesh## after each deformation.(I don't think this would be problem). * Both remeshers require a conversion from the sculpt geometry to ##Mesh## in order to work. Voxel should be expected to work with high poly meshes, and it already contains a ##Mesh## -> ##BMesh## -> ##Mesh## conversion which takes up to 80% of its execution time. * Trimming tools require a conversion to ##BMesh## in order to use the boolean solver. * Mesh slicing and extracting require the sculpt geometry with mask and face set datalayers as ##Mesh## * Face sets form Edit mode selection requires ##Mesh## selection flags. This can be copied on geometry creation as they are not modified by sculpt mode. * Dyntopo needs to be discussed separately. There should not be a problem to use ##BMesh## for it.
Julien Kaspar added this to the Sculpt, Paint & Texture project 2023-02-08 10:20:48 +01:00
Philipp Oeser removed the
Interest
Sculpt, Paint & Texture
label 2023-02-10 09:12:02 +01:00
Member

I am removing the Needs Triage label. This is under the general rule that Design and TODO tasks should not have a status.

If you believe this task is no longer relevant, feel free to close it.

I am removing the `Needs Triage` label. This is under the general rule that Design and TODO tasks should not have a status. If you believe this task is no longer relevant, feel free to close it.
Alaska removed the
Status
Needs Triage
label 2024-04-07 06:07:24 +02:00
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 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#85296
No description provided.