Regression: Cycles: unstable triangulation of mesh in viewport #106469

Closed
opened 2023-04-02 22:55:43 +02:00 by Max Mustermann · 9 comments

System Information
Operating system: Fedora Linux 37 (Wayland)
Graphics card: AMD

Blender Version
Broken: 3.5.0 (flatpak)
Worked: 3.4.1 (fedora rpm)

Exposed/Caused by 511ac66dab

Short description of error

There are two observable issues:

  • Mesh edit mode (quad) triangulation (edit mode overlay) is flickering when previewing with Cycles.
  • Cycles triangulation itself doesn't seem to flicker here, but the triangulation result is the inverse of what is in object mode.

Steps to reproduce

  • Enable cycles.
  • Enable shaded viewport.
  • Enter edit mode.
  • Rotate top face of default cube by -72° on Z-Axis.
  • Extrude top face.
  • Move extruded top face.
  • The shape of the default cube now flickers.

Note:

  • When Cycles preview is showing the wrong triangulation, switching back to material/solid shading would retain the wrong triangulation, move the mesh will refresh the state and the triangulation looks stable again.
**System Information** Operating system: Fedora Linux 37 (Wayland) Graphics card: AMD **Blender Version** Broken: 3.5.0 (flatpak) Worked: 3.4.1 (fedora rpm) Exposed/Caused by 511ac66dab **Short description of error** There are two observable issues: - Mesh edit mode (quad) triangulation (edit mode overlay) is flickering when previewing with Cycles. - Cycles triangulation itself doesn't seem to flicker here, but the triangulation result is the inverse of what is in object mode. **Steps to reproduce** - Enable cycles. - Enable shaded viewport. - Enter edit mode. - Rotate top face of default cube by -72° on Z-Axis. - Extrude top face. - Move extruded top face. - The shape of the default cube now flickers. Note: - When Cycles preview is showing the wrong triangulation, switching back to material/solid shading would retain the wrong triangulation, move the mesh will refresh the state and the triangulation looks stable again.
Max Mustermann added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-04-02 22:55:44 +02:00
Iliya Katushenock added the
Interest
Modeling
Interest
Render & Cycles
labels 2023-04-02 23:02:08 +02:00
Author

It is easier to see against a dark background.

It is easier to see against a dark background.
Member

Can confirm the issue. Might relate to threading and different triangulation algorithm used in bmesh and mesh.

I'll attach a file on the first post to show the problem.

Can confirm the issue. Might relate to threading and different triangulation algorithm used in bmesh and mesh. I'll attach a file on the first post to show the problem.
YimingWu added
Module
Render & Cycles
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-04-03 11:20:04 +02:00
Member

Probably also caused by 16fbadde36

We had #106134 already, but I can confirm this is still happening (even after 5efa39096c)

@HooglyBoogly : mind checking?

Probably also caused by 16fbadde363c8074ec725fa1e1079add096bd741 We had #106134 already, but I can confirm this is still happening (even after 5efa39096c8e242c9bf9ed7b7a25124692e2b9d0) @HooglyBoogly : mind checking?
Member

I suspect #106430 is also affected by that commit...

I suspect #106430 is also affected by that commit...
Philipp Oeser changed title from Cycles: unstable triangulation of mesh in viewport to Regression: Cycles: unstable triangulation of mesh in viewport 2023-04-03 11:30:08 +02:00
Member

I suspect #106430 is also affected by that commit...

Think this is more about 6c774feba2 (but would have to check... lets continue discussion in #106430)

> I suspect #106430 is also affected by that commit... Think this is more about 6c774feba2c9a1eb5834646f597a0f2c63177914 (but would have to check... lets continue discussion in #106430)
Member

Not caused by 16fbadde36, will bisect the real culprit

Not caused by 16fbadde36, will bisect the real culprit
Member

Exposed/Caused by 511ac66dab

Havent checked if cycles triangulation is actually the same as viewport triangulation (or if this is another bug).

@HooglyBoogly : mind checking?

Exposed/Caused by 511ac66dabf170de2e0e445afbee261ddb944cf6 Havent checked if cycles triangulation is actually the same as viewport triangulation (or if this is another bug). @HooglyBoogly : mind checking?
Hans Goudey self-assigned this 2023-04-11 21:35:48 +02:00
Member

It looks like the problem is in mesh_calc_tessellation_for_face_impl. This gives different results depending on whether face normals happen to be calculated already or not. In other words, is_quad_flip_v3_first_third_fast_with_normal is not equivalent to is_quad_flip_v3_first_third_fast. I'm surprised this was only exposed now actually, it looks like this issue has been there for a while, since 2d60c496a2. It's just visible because Cycles copies meshes that are in edit mode, which doesn't carry over any cached triangulation.

I have some ideas I'd like to investigate next:

  • Check the performance of just calculating the quad normal in that function.
  • Copy logic from BM_face_triangulate MOD_TRIANGULATE_QUAD_BEAUTY. Check to see if the performance is much worse
  • Figure out the history of f088c6b9f6. Where does this flipping mechanism come from, compared to something simpler like equalizing the area of the two triangles (mentioned here)
  • Also, random unrelated thought: it might be good to add a runtime tag to some primitive meshes like grids to avoid this check, it's totally unnecessary when they haven't been deformed.
  • Figure out why the "fast" version of the function is used for Mesh evaluation when the "non-fast" version of the function is used for BMesh.

@ideasman42 From the git history it looks like you've worked on mesh triangulation in the past, do you have any thoughts about this, maybe about which of those ideas seem worth investigating?

I attached a simpler reproduction with a single face.

no poly normals poly normals
image image
It looks like the problem is in `mesh_calc_tessellation_for_face_impl`. This gives different results depending on whether face normals happen to be calculated already or not. In other words, `is_quad_flip_v3_first_third_fast_with_normal` is not equivalent to `is_quad_flip_v3_first_third_fast`. I'm surprised this was only exposed now actually, it looks like this issue has been there for a while, since 2d60c496a200288f100c11845ccb196f04e45ba3. It's just visible because Cycles copies meshes that are in edit mode, which doesn't carry over any cached triangulation. I have some ideas I'd like to investigate next: - Check the performance of just calculating the quad normal in that function. - Copy logic from `BM_face_triangulate` `MOD_TRIANGULATE_QUAD_BEAUTY`. Check to see if the performance is much worse - Figure out the history of f088c6b9f6d69e7f1af15a059f122589ee6a39ab. Where does this flipping mechanism come from, compared to something simpler like equalizing the area of the two triangles (mentioned [here](https://computergraphics.stackexchange.com/questions/10180/how-to-decide-which-way-to-triangulate-a-quad)) - Also, random unrelated thought: it might be good to add a runtime tag to some primitive meshes like grids to avoid this check, it's totally unnecessary when they haven't been deformed. - Figure out why the "fast" version of the function is used for `Mesh` evaluation when the "non-fast" version of the function is used for `BMesh`. @ideasman42 From the git history it looks like you've worked on mesh triangulation in the past, do you have any thoughts about this, maybe about which of those ideas seem worth investigating? I attached a simpler reproduction with a single face. | no poly normals | poly normals | | --------------- | ------------ | | ![image](/attachments/7ce6a0c9-8f05-4e64-90ca-48461bb7dd09) | ![image](/attachments/0329518b-4dc7-4567-9955-5a882052c7f4) |
Hans Goudey added
Type
Bug
and removed
Type
Report
labels 2023-04-14 22:43:49 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-04-21 07:04:18 +02:00
Member

At least in one case (a large UV sphere primitive), this fix seems to have made triangulation a bit faster too, that's nice!

BEFORE: Timer 'looptris_calc_with_normals': (Average: 7.5 ms, Min: 7.3 ms, Last: 7.6 ms)
AFTER: Timer 'looptris_calc_with_normals': (Average: 7.1 ms, Min: 6.9 ms, Last: 7.1 ms)
At least in one case (a large UV sphere primitive), this fix seems to have made triangulation a bit faster too, that's nice! ``` BEFORE: Timer 'looptris_calc_with_normals': (Average: 7.5 ms, Min: 7.3 ms, Last: 7.6 ms) AFTER: Timer 'looptris_calc_with_normals': (Average: 7.1 ms, Min: 6.9 ms, Last: 7.1 ms) ```
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 project
No Assignees
4 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#106469
No description provided.