0
\$\begingroup\$

Well, I'm continuing this question without answer (Smoothing random noises with different amplitudes) and I have another question.

I have opted to use the contour/shadow of a shape (https://stackoverflow.com/questions/53400394/translating-transforming-list-of-points-from-its-center-with-an-offset-distance).

This contour/shadow is bigger than the current path. I used this repository (https://github.com/n-yoda/unity-vertex-effects) to recreate the shadow. And this works pretty well, except for one fact.

To know the height of all points (obtained by this shadow algorithm (Line 13 of ModifiedShadow.cs & Line 69 of CircleOutline.cs)) I get the distance of the current point to the center and I divide between the maximum distance to the center:

float dist = orig.Max(v => (v - Center).magnitude);
foreach Point in poly --> float d = 1f - (Center - p).magnitude / dist;

Where orig is the entire list of points obtained by the shadow algorithm. D is the height of the shadow.

But the problem is obvious I get a perfect circle:

...

In red and black to see the contrast:

...

And this is not what I want:

...

As you can see this not a perfect gradient. Let's explain what's happening.

I use this library to generate noises: https://github.com/Auburns/FastNoise_CSharp

Note: If you want to know what I use to get noises with different amplitude: https://stackoverflow.com/questions/53356072/smoothing-random-noises-with-different-amplitudes (see first block of code), to see this in action, see this repo

...

  • Green background color represent noises with a mean height of -0.25 and an amplitude of 0.3
  • White background color represent noises with a mean height of 0 and an amplitude of 0.1
  • Red means 1 (total interpolation for noises corresponding to white pixels)
  • Black means 0 (total interpolation for noises corresponding to green pixels)

That's why we have this output:

...

Actually, I have tried comparing distances of each individual point to the center, but this output a weird and unexpected result.

Actually, I don't know what to try...

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.