Page MenuHome

Surface Deform modifier - distortion on bind (depending on scale)
Closed, ResolvedPublic


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: rB26bd5ebd42e3
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:

Gif showing problem:

Simplified test case:

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Jan 24 2020, 10:39 AM

Can confirm, checking...

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

Philipp Oeser (lichtwerk) renamed this task from Surface Deform modifier - distortion on bind to Surface Deform modifier - distortion on bind (depending on scale).Jan 24 2020, 11:13 AM
Philipp Oeser (lichtwerk) updated the task description. (Show Details)

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]

@Luca Rood (LucaRood) : Known Isssue?

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:

     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.

@Philipp Oeser (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 @Cody Winchester (CodyWinch) 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.