private IEnumerable <Vector3> GetLightsDistributionPoisson(int size, float θFrom, float θTo) { Vector2[] poisson; if (size >= 1000) { if (_poissonDisk == null && _poissonDiskWeak != null && _poissonDiskWeak.TryGetTarget(out var value)) { _poissonDisk = value; } if (_poissonDisk?.Count != size) { _poissonDisk = UniformPoissonDiskSampler.SampleSquare(size, false); _poissonDiskWeak = new WeakReference <List <Vector2> >(_poissonDisk); } poisson = _poissonDisk.ToArray(); } else { poisson = UniformPoissonDiskSampler.SampleSquare(size, false).ToArray(); } CropPoisson(poisson, (θFrom.ToRadians() + MathF.PI / 2f).Cos(), (θTo.ToRadians() + MathF.PI / 2f).Cos()); foreach (var point in poisson) { var θ = point.Y.Clamp(-0.9999f, 0.9999f).Acos() - MathF.PI / 2f; var φ = point.X * MathF.PI; var direction = MathF.ToVector3Rad(θ, φ); yield return(direction); } }
private void InitializeAccumulationDof() { _lazyAccumulationDofPoissonDiskSamples = Lazier.Create(() => Reorder(UniformPoissonDiskSampler.SampleCircle(_accumulationDofIterations))); _lazyAccumulationDofPoissonSquareSamples = Lazier.Create(() => UniformPoissonDiskSampler.SampleSquare(_accumulationDofIterations, false).ToArray()); }