Gaussian Falloff Format for Mesh Manipulation

1.4k Views Asked by At

This return below is defined as a gaussian falloff. I am not seeing e or powers of 2, so I am not sure how this is related to the Gaussian falloff, or if it is the wrong kind of fallout for me to use to get a nice smooth deformation on my mesh:

 Mathf.Clamp01 (Mathf.Pow (360.0, -Mathf.Pow (distance / inRadius, 2.5) - 0.01))

where Mathf.Clamp01 returns a value between 0 and 1.

inRadius is the size of the distortion and distance is determined by:

        sqrMagnitude = (vertices[i] - position).sqrMagnitude;
        // Early out if too far away
        if (sqrMagnitude > sqrRadius)
            continue;
        distance = Mathf.Sqrt(sqrMagnitude);

vertices is a list of mesh vertices, and position is the point of mesh manipulation/deformation.

My question is two parts:

1) Is the above actually a Gaussian falloff? It is expontential, but there does not seem to be the crucial e or power of 2... (Updated - I see how the graph seems to decrease smoothly in a Gaussian-like way. Perhaps this function is not the cause for problem 2 below)

2) My mesh is not deforming smoothly enough - given the above parameters, would you recommend a different Gaussian falloff?

1

There are 1 best solutions below

1
On

Don't know about meshes etc. but lets see that math:

f=360^(-0.1- ((d/r)^2.5) ) looks similar enough to gausian function to make a "fall off". i'll take the exponent apart to show a point: f= 360^( -(d/r)^2.5)*360^(-0.1)=(0.5551)*360^( -(d/r)^2.5)

if d-->+inf then f-->0 if d-->+0 then f-->(0.5551) the exponent of 360 is always negative (assuming 'distance' and 'inRadius' are always positive) and getting bigger (more negative) almost cubicly ( power of 2.5) with distance thus the function is "falling off" and doing it pretty fast.

Conclusion: the function is not Gausian because it behaves badly for negative input and probably for other reasons. It does exibits the "fall off" behavior you are looking for. Changing r will change the speed of the fall-off. When d==r the f=(1/360)*0.5551. The function will never go over 0.5551 and below zero so the "clipping" in the code is meaningless.

I don't see any see any specific reason for the constant 360 - changing it changes the slope a bit.

cheers!