Surface Deform modifier - distortion on bind (depending on scale) #73348

Closed
opened 2020-01-23 21:47:43 +01:00 by Jose Conseco · 13 comments

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 660/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.15

Blender Version
Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-20 14:27, hash: 26bd5ebd42
Same on blender 2.82 daily build
Worked: (optional)

Short description of error
When pressing 'Bind' in surface deform modifier, some small distortion is applied to mesh, even though is should not change at all.

Exact steps for others to reproduce the error

  1. Press 'Bind' on surface deform modifier. Mesh gets distorted slightly on fingers. This is problematic.
    Blend file:
    bind_problem.blend
    Gif showing problem:
    bind_distortion.gif

Simplified test case:
#73348.blend

**System Information** Operating system: Windows-10-10.0.18362 64 Bits Graphics card: GeForce GTX 660/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.15 **Blender Version** Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-20 14:27, hash: `26bd5ebd42` Same on blender 2.82 daily build Worked: (optional) **Short description of error** When pressing 'Bind' in surface deform modifier, some small distortion is applied to mesh, even though is should not change at all. **Exact steps for others to reproduce the error** 1. Press 'Bind' on surface deform modifier. Mesh gets distorted slightly on fingers. This is problematic. Blend file: [bind_problem.blend](https://archive.blender.org/developer/F8297785/bind_problem.blend) Gif showing problem: ![bind_distortion.gif](https://archive.blender.org/developer/F8297789/bind_distortion.gif) Simplified test case: [#73348.blend](https://archive.blender.org/developer/F8299067/T73348.blend)
Author

Added subscriber: @JoseConseco

Added subscriber: @JoseConseco
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Can confirm, checking...

Can confirm, checking...
Member

Seems to be a precision problem somewhere, if I scale the whole thing by 10, issues seem to vanish...

Seems to be a precision problem somewhere, if I scale the whole thing by 10, issues seem to vanish...
Philipp Oeser changed title from Surface Deform modifier - distortion on bind to Surface Deform modifier - distortion on bind (depending on scale) 2020-01-24 11:13:24 +01:00
Member

Added subscriber: @LucaRood-3

Added subscriber: @LucaRood-3
Member

Well, even if this can be worked around by scaling, will still keep open, since there seems to be some mismatch going on [which really shouldnt be the case]

@LucaRood-3 : Known Isssue?

Well, even if this can be worked around by scaling, will still keep open, since there seems to be some mismatch going on [which really shouldnt be the case] @LucaRood-3 : Known Isssue?
Member

Added subscriber: @Mets

Added subscriber: @Mets

Added subscriber: @CodyWinchester

Added subscriber: @CodyWinchester

Looking into this and I found the problem lies in the Ngon method bindings. It is the only method that returns errors on the small scale that go away once scaled up.

In MOD_surfacedeform.c the line:

        interp_weights_poly_v2( 
             sdbind->vert_weights, bpoly->coords_v2, bpoly->numverts, bpoly->point_v2);

is where things go wrong. The weight gets calculated incorrectly due to the small size of the geometry, which causes the calculations to be off.

Inside of interp_weights_poly_v2 is the line:

       ht = mean_value_half_tan_v2(&d_curr, &d_next);

in this function if the area it calculates is too small it returns 0.0f which causes the weights to be wrong. Since the geometry is so small some polys return an area of 0.0f when scaled up they are correct.

If I scale the data put into interp_weights_poly_v2 and interp_weights_tri_v3 and then unscale it afterwards the bug goes away as the weight calculation is using much larger values and doesn't fail due to float precision. Depending on the factor I scale the data is how much smaller the geometry can be.

If I remove the Ngon method as an option entirely it works with no errors at the current scale, but if scaled down again by .1 it still fails.

Looking into this and I found the problem lies in the Ngon method bindings. It is the only method that returns errors on the small scale that go away once scaled up. In MOD_surfacedeform.c the line: ``` interp_weights_poly_v2( sdbind->vert_weights, bpoly->coords_v2, bpoly->numverts, bpoly->point_v2); ``` is where things go wrong. The weight gets calculated incorrectly due to the small size of the geometry, which causes the calculations to be off. Inside of interp_weights_poly_v2 is the line: ``` ht = mean_value_half_tan_v2(&d_curr, &d_next); ``` in this function if the area it calculates is too small it returns 0.0f which causes the weights to be wrong. Since the geometry is so small some polys return an area of 0.0f when scaled up they are correct. If I scale the data put into interp_weights_poly_v2 and interp_weights_tri_v3 and then unscale it afterwards the bug goes away as the weight calculation is using much larger values and doesn't fail due to float precision. Depending on the factor I scale the data is how much smaller the geometry can be. If I remove the Ngon method as an option entirely it works with no errors at the current scale, but if scaled down again by .1 it still fails.
Cody Winchester self-assigned this 2020-02-07 22:51:12 +01:00
Member

@lichtwerk, kinda known issue. The whole SDef code is kinda unstable, and in ideal circumstances I'd like to completely rewrite it. I've had some thoughts on better algorithms, though no time for that at the moment.
But @CodyWinchester seems to have tracked down where this issue lies, and it seems like it could be a simple fix. I expressed my thoughts at D6782.

@lichtwerk, kinda known issue. The whole SDef code is kinda unstable, and in ideal circumstances I'd like to completely rewrite it. I've had some thoughts on better algorithms, though no time for that at the moment. But @CodyWinchester seems to have tracked down where this issue lies, and it seems like it could be a simple fix. I expressed my thoughts at [D6782](https://archive.blender.org/developer/D6782).

This issue was referenced by c5d0a23204

This issue was referenced by c5d0a2320498d1feb7cc2c68fc6504bb187d5a8d

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
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
7 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#73348
No description provided.