Poisson Disc Sampling

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
SelfDotX
Prole
Posts: 25
Joined: Sun Oct 02, 2022 5:06 pm

Poisson Disc Sampling

Post by SelfDotX »

Poisson disc sampling, an algorithm for generating tightly-packed points which are all some minimum distance from one another.

Based on: this video - the first few minutes are also a good description.

A visualization of the selection process with some color added based on the 'age' the point was picked.
Poisson.png
Poisson.png (846.83 KiB) Viewed 5086 times
and the actual points table displayed as... points
Poisson2.png
Poisson2.png (27.56 KiB) Viewed 5086 times
Attachments
Lua_PoissonDiskSampler.love
(6.08 KiB) Downloaded 174 times
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Poisson Disc Sampling

Post by ReFreezed »

This is pretty useful stuff!
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
SelfDotX
Prole
Posts: 25
Joined: Sun Oct 02, 2022 5:06 pm

Re: Poisson Disc Sampling

Post by SelfDotX »

Thanks! It started out as a simple starfield generator, but the more 'knobs' I add and 'dials' I turn, I'm seeing a lot of possibilities here. Since I really need to get around to learning shaders, I think the first project will be something that takes in the points and outputs 'nebula' type shading based on point density/age.
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Poisson Disc Sampling

Post by darkfrei »

I like this explanation:

https://youtu.be/flQgnCUxHlw

:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Poisson Disc Sampling

Post by darkfrei »

My implementation (move mouse to create new circles)
press space to switch the view
press S to reset the field
press G to hide he grid
:awesome:
poisson-disc-sampling-02.png
poisson-disc-sampling-02.png (116.91 KiB) Viewed 4905 times
https://github.com/darkfrei/love2d-lua- ... c-sampling

https://www.youtube.com/watch?v=PlQuPHga82Q
Attachments
poisson-disc-sampling-02.love
license CC0
(1.57 KiB) Downloaded 146 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Poisson Disc Sampling

Post by darkfrei »

Situation, if the Poisson Disc Sampling allows just one connection to the old points.
poisson-disc-sampling-03.png
poisson-disc-sampling-03.png (16.78 KiB) Viewed 4888 times
https://youtu.be/cqcDK5IPvhM



https://github.com/darkfrei/love2d-lua- ... c-sampling
Attachments
poisson-disc-sampling-03.love
(1.66 KiB) Downloaded 149 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Poisson Disc Sampling

Post by ReFreezed »

@darkfrei
Your implementation doesn't look quite as random and evenly distributed as the original. I see more patterns and lines among the samples.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Poisson Disc Sampling

Post by darkfrei »

ReFreezed wrote: Wed Oct 19, 2022 1:34 pm @darkfrei
Your implementation doesn't look quite as random and evenly distributed as the original. I see more patterns and lines among the samples.
You are right, it's not the same: in the original PDS the generated point will be chosen randomly, but here the generated point will be chosen near the mouse position is only.
But you can simulate the original simulation if you move mouse from starting point to the outside.

Points:
2022-10-19T17_02_35-poisson-disc-sampling-04.png
2022-10-19T17_02_35-poisson-disc-sampling-04.png (57.79 KiB) Viewed 4861 times
Connections:
2022-10-19T17_02_50-poisson-disc-sampling-04.png
2022-10-19T17_02_50-poisson-disc-sampling-04.png (679.13 KiB) Viewed 4861 times
https://youtu.be/SdPaPliAi7s
Attachments
poisson-disc-sampling-04.love
(1.99 KiB) Downloaded 149 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: alexjgriffith and 2 guests