Currently I have loads of these shapes that I have manually created. And my script selects one of them at random and then subtracts it from perlin noise which then results in something similar to an island shape.
I would rather not have a selection of ranom shapes to choose from but have a random shape generated.
The shape would need to have a fade/falloff from black to white around the edges as shown in the image.
Does anyone have any ideas on how I would go about doing this?
I have no idea where I would even start at tackling this.
Hi, thanks for getting back to me. would ou be able to elaborate on this slightly? I’m not sure what you mean with using perlin noise directly with a step function?
Hi, thanks for providing that detail, it will come in handy for my project for sure. I will need to figure out how to extract a single one of those shapes… another question for another time though after ive experimented…
However I’m not sure it will help for this specific purpose as there a more requirements that need to be met.
For example the shape that needs to be generated would need to be just under 256 X 512 with white around the edges.
Notice in the following images each shape is almost fits the entirety of the 256 x 512 boundry but doesn’t reach the edge of that boundry. All of the black blobs looks like variations of the same thing, they are similar in size, and they almost reach the corners of the boundry but not quite, and they all take up pretty much the same amount of space.
Is it possible to generate blobs/shapes similar to the above images and store in a bitmap for later use?
It’s certainly possible, perhaps not super-easy, and the results perhaps won’t be as good as what you authored by hand above.
One way is to think small, like 10x20 pixels or something…
At the tiny pixel level, one approach is to start full white, pick a random pixel, set it black, then pick all subsequent random pixels to be adjacent to an existing black pixel, iterating until you have enough black vs white and keeping away from the immediate edge.
See this blown-up pixel thing I just ripped out:
Then just blit it with bilinear filtering on to make it larger:
EDIT: see also my post lower down about the blobozoan
ALTERNATELY, building upon what @PraetorBlue said above, use Perlin noise to make your large island blobby shape by passing it through a simple boxy bounds container like this:
generate some perlin noise islands with a step filter
pick a random black (or white pixel) in the image
using a flood-fill algorithm (DFS or BFS), find all connected pixels of the same color
once you have all those pixels, you have now identified one “island”
optional: if the island is touching any of the borders of the image, try again until you find one that is not touching a border. (if you find none, start over with a new noise sample entirely). You can also use similar logic to reject other “undesirable” properties of the island such as being too small.
Check the bounds of the island and rescale it as necessary to fit into your desired oblong rectangular shape more nicely
you specifically want a bitmap but Unity has beautiful quick method for a png ! My fav.
All you gotta do is grab the first point and then do some adjacency math. X + -1 or 1, Y + -1 or 1 now a blobszoan will form. Once you’re in the for loop or algorithm; that generates points you can do a lot of experimenting for the perfect blob formula.
All of this is very helpfull. Thank you so much. Looks like I have alot of playing about to do.
Ahh I only mentioned bitmap as a generic term for picture. The format isn’t really that important as ill only be using the pixel value which will range from 0 to 1 using .GetPixel(x, y).grayscale
Because I’ll only be using the value of the pixel I can probably eventually do all of this without the need for an image, but while I’m developing it I want to be able to see it.
Procgen of any kind basically means “lots of playing around”… it is one of my most favorite funnest things to do in gamedev… the feeling when you nail the effect and get what you want is pure gold. Stick with it.
And there are other examples in that MakeGeo project I linked above.