cemyuksel/cyCodeBase

Example of adaptive weightFunction?

alecjacobson opened this issue · 1 comments

I'm loving the blue noise sampler on surfaces in 3D. In the default "uniform importance" mode it's working great! Thanks for sharing this great implementation of a great algorithm.

I'm struggling to get the weightFunction working correctly for adaptive importance. Wondering if you could give some pointers?

For example, I'm trying to create sampling of this rectangle with more samples toward the center and decreasing "smoothly" toward the edges.

I tried using this as my weightFunction:

  const auto weight = 
    [d_min, alpha](
    PointType const & p0, 
    PointType const & p1, 
    FType d2, 
    FType d_max)
  {
    FType d = cy::Sqrt(d2)*(3.0-2.0*(1.0-p0.Length()));
    return std::pow( FType(1) - d/d_max, alpha );
  };

But the result is clumpy:

image

Your weight function seems fine to me. It might be related to the bounds of p0.Length(). It should not be greater than 1. You may need to scale it accordingly.