Page 1 of 2

How to generate clumps of minerals?

Posted: Tue Oct 19, 2021 5:55 pm
by Gunroar:Cannon()
Which algorithm could I use to generate ore veins in a 2D (side) view? Where I can adjust how much the ore is generated?

Image
Kind of like this

Re: How to generate clumps of minerals?

Posted: Tue Oct 19, 2021 8:14 pm
by pgimeno
Have you tried thinking instead of asking?
  1. Pick a random coordinate
  2. Pick two random numbers for offset.
  3. If coordinate + offset is dirt, replace it with mineral.
  4. Repeat steps 2 and 3 as many times as desired.

Re: How to generate clumps of minerals?

Posted: Tue Oct 19, 2021 9:58 pm
by Gunroar:Cannon()
pgimeno wrote: Tue Oct 19, 2021 8:14 pm Have you tried thinking instead of asking?
Image

Hmmm, that's a nice and clean solution, I guess I was expecting something like cellular or perlin noise. :? :ultrahappy:
Also does that method deal with bigger clumps? From what I understand won't most of the clumps look the same?

Re: How to generate clumps of minerals?

Posted: Tue Oct 19, 2021 10:49 pm
by darkfrei
Gunroar:Cannon() wrote: Tue Oct 19, 2021 9:58 pm Also does that method deal with bigger clumps? From what I understand won't most of the clumps look the same?
Create particle, add some mineral here.
Create new particle and move both of them in random direction.
Repeat until you want.

Re: How to generate clumps of minerals?

Posted: Tue Oct 19, 2021 11:06 pm
by Gunroar:Cannon()
darkfrei wrote: Create particle, add some mineral here.
Create new particle and move both of them in random direction.
Repeat until you want.
What's a particle in your terminology?

Re: How to generate clumps of minerals?

Posted: Wed Oct 20, 2021 10:00 am
by darkfrei
Gunroar:Cannon() wrote: Tue Oct 19, 2021 11:06 pm
darkfrei wrote: Create particle, add some mineral here.
Create new particle and move both of them in random direction.
Repeat until you want.
What's a particle in your terminology?
The thing that will be created, it moves and disappears, maybe generates other particles.
It can move freeways as

Code: Select all

x,y=x+dt*vx,y+dt*vy
or chunk-based, like

Code: Select all

x,y=x+math.random(-1,1)*chunkSize, y+math.random(-1,1)*chunkSize
.
After the movement it can check if it can place here some ore, creates another particle, counts one step down and if it is lower than lowest value, then disappears.

Re: How to generate clumps of minerals?

Posted: Wed Oct 20, 2021 12:57 pm
by milon
There are going to be dozens - if not hundreds - of ways to accomplish this. The "best" will be determined by your desired outcome. Do you want random blobs? Seams of ore that branch? Tiny specs here and there? etc... You could certainly use a cellular automata (you'll get a LOT of ore) or a 2D noise map (with a set threshold) for a more fine-tuneable setup.

Re: How to generate clumps of minerals?

Posted: Wed Oct 20, 2021 1:44 pm
by Gunroar:Cannon()
I kind of want to use both random blobs (I guess pgimeno's method works for that) and seems of ore that branch...

Re: How to generate clumps of minerals?

Posted: Wed Oct 20, 2021 3:17 pm
by darkfrei
Gunroar:Cannon() wrote: Wed Oct 20, 2021 1:44 pm I kind of want to use both random blobs (I guess pgimeno's method works for that) and seems of ore that branch...
Please try this solution (click on the screen):



ore-patches-01.png
ore-patches-01.png (62.38 KiB) Viewed 4974 times
ore-patches-01.love
(1.06 KiB) Downloaded 162 times
ore-patches-02.love
(1.17 KiB) Downloaded 176 times

Re: How to generate clumps of minerals?

Posted: Wed Oct 20, 2021 8:02 pm
by Gunroar:Cannon()
Woah, that's really cool though advanced. So I could just make the white parts minerals . I just ran it but haven't checked out the code, any way to scale it?