Help with autoplacement for multi level (3D) map
Help with autoplacement for multi level (3D) map
In vanilla everything is placed on the surface of the world. You don't have to dig down into the ground to mine ores, they are simply lying around on top. This is hardly realistic.
But factorio supports having multiple surfaces. So it wouldn't be hard to have actual mines underground using multiple surfaces as layers at different depths.
Now here comes my problem:
Can I change the autoplacement of ores in such a way that the layers look realistic? That means that if one layer has a huge iron ore patch then the layer above and below should also have iron ore patches at about the same place. Ore patches from different layers combined should look like a 3D blob of ore.
Similar problem: Deep water on the surface should also be water in the first layer (or first few depending on depth). The difference to ore would be that water (I think) shouldn't have underground caverns. On the other hand underground seas or rivers might be fun too.
But factorio supports having multiple surfaces. So it wouldn't be hard to have actual mines underground using multiple surfaces as layers at different depths.
Now here comes my problem:
Can I change the autoplacement of ores in such a way that the layers look realistic? That means that if one layer has a huge iron ore patch then the layer above and below should also have iron ore patches at about the same place. Ore patches from different layers combined should look like a 3D blob of ore.
Similar problem: Deep water on the surface should also be water in the first layer (or first few depending on depth). The difference to ore would be that water (I think) shouldn't have underground caverns. On the other hand underground seas or rivers might be fun too.
Re: Help with autoplacement for multi level (3D) map
Re: Help with autoplacement for multi level (3D) map
Or you can go to RSO's way: place all resources by the script only. You can make your own maths for ores placing, just make new noise and change the section level on each surface.
Re: Help with autoplacement for multi level (3D) map
Placing all resources by script would certainly work. Good to have an example for that.
As for making new noise.... Do you mean specifying a different noise layer? As far as I can see the noise layers are defined by the game and are all non correlated 2D perlin noise. Using different noise layers per surface gives ore at different positions. I need loosely correlated layers.
PS: Can anyone recommend a noise function for 3D?
As for making new noise.... Do you mean specifying a different noise layer? As far as I can see the noise layers are defined by the game and are all non correlated 2D perlin noise. Using different noise layers per surface gives ore at different positions. I need loosely correlated layers.
PS: Can anyone recommend a noise function for 3D?
- WeirdConstructor
- Inserter
- Posts: 39
- Joined: Wed Aug 08, 2018 6:31 am
- Contact:
Re: Help with autoplacement for multi level (3D) map
Just use any RNG or even hash function (like xorshift or whatever, even the Lua random number generator might wirk)
and throw in the coordinates as seed (hashed and/or xor'ed x/y/z) and you got your value for that position.
You can mix multiple octaves and interpolate for more smooth transitions to neighbor coordinates.
Re: Help with autoplacement for multi level (3D) map
That would give me white noise with single tiles of ores randomly distributed all across the surface.WeirdConstructor wrote: βMon Sep 17, 2018 1:37 pmJust use any RNG or even hash function (like xorshift or whatever, even the Lua random number generator might wirk)
and throw in the coordinates as seed (hashed and/or xor'ed x/y/z) and you got your value for that position.
You can mix multiple octaves and interpolate for more smooth transitions to neighbor coordinates.
I want a nice patch of ore over 3 dimensions. Like a raisin in a cake.
- WeirdConstructor
- Inserter
- Posts: 39
- Joined: Wed Aug 08, 2018 6:31 am
- Contact:
Re: Help with autoplacement for multi level (3D) map
Thats why I said u should mix/blend multiple resolutions aka octaves with interpolation. At x u sample x and x modulo 10 and other modulos. The remainder of that modulo you use to interpolate between (x modulo 10) and ((x modulo 10) + 1). You get a noise value for each octave and you can blend them at will. Thats basically what most call "perlin noise" even though real perlin noise is a bit more specific.mrvn wrote: βMon Sep 17, 2018 1:49 pmThat would give me white noise with single tiles of ores randomly distributed all across the surface.WeirdConstructor wrote: βMon Sep 17, 2018 1:37 pmJust use any RNG or even hash function (like xorshift or whatever, even the Lua random number generator might wirk)
and throw in the coordinates as seed (hashed and/or xor'ed x/y/z) and you got your value for that position.
You can mix multiple octaves and interpolate for more smooth transitions to neighbor coordinates.
I want a nice patch of ore over 3 dimensions. Like a raisin in a cake.
Re: Help with autoplacement for multi level (3D) map
I think this might be useful:
https://en.wikipedia.org/wiki/Metaballs
RSO uses 2D variant of those to generate ores. It might be pretty easy to use current gen as "base" and expand them in z dimension.
https://en.wikipedia.org/wiki/Metaballs
RSO uses 2D variant of those to generate ores. It might be pretty easy to use current gen as "base" and expand them in z dimension.
Re: Help with autoplacement for multi level (3D) map
For better understanding of 3d noise, you must make nice 2d noise before.
I've made some 2d noise here: NewIslands.
The simple noise is:
h=cos(X)*cos(Y), if h > 0.5 then b = true else b = false end, but this noise is absolutely not noise.
Some complicated (more octaves):
h=(A*cos(X)*cos(Y)+B*cos(2*X)*cos(2*Y))/(A+B)
h=(A*cos(X)*cos(Y)+B*cos(2*X)*cos(2*Y)+C*cos(4*X)*cos(4*Y))/(A+B+C) etc. All of them are symmetrically, you are need just add some odd stuff and shift it.
The example for 1D noise (shifted by x to 10):
y = (cos(x)+(1/2)*cos(3.1(x+10))+(1/3)*cos(5.1(x+10))+(1/5)*cos(8.1(x+10)))/(1+1/2+1/3+1/5)
Re: Help with autoplacement for multi level (3D) map
That would wok well with the random dots from the last FFF.orzelek wrote: βMon Sep 17, 2018 4:24 pmI think this might be useful:
https://en.wikipedia.org/wiki/Metaballs
RSO uses 2D variant of those to generate ores. It might be pretty easy to use current gen as "base" and expand them in z dimension.
Re: Help with autoplacement for multi level (3D) map
But you are need to define each metaball! It's not good for unlimited map.
Re: Help with autoplacement for multi level (3D) map
It's not a big problem - RSO just rolls randomly few of them (positive and negative) to create nicely looking patches. A bit tricky part is getting patch of size you actually want and balancing total amount of resources. I'm not sure why unlimited map would be a problem?
Re: Help with autoplacement for multi level (3D) map
Exactly. I would use the random dots from the last FFF as locations of the metaballs and then the combination of them gives the patch.orzelek wrote: βThu Sep 20, 2018 11:36 amIt's not a big problem - RSO just rolls randomly few of them (positive and negative) to create nicely looking patches. A bit tricky part is getting patch of size you actually want and balancing total amount of resources. I'm not sure why unlimited map would be a problem?
Re: Help with autoplacement for multi level (3D) map
So looks like cosinus-octaves-noise:
Every tile on the map needs the same calculating time.
Every tile on the map needs the same calculating time.
Code: Select all
function cos_octaves (octaves, position, p)
local h = 0
local summ = 0
if octaves then
-- log ('octaves = ' .. serpent.block (octaves))
for i, octave in pairs (octaves) do
local x = position.x*math.cos(octave.teta)-position.y*math.sin(octave.teta)
local y = position.x*math.sin(octave.teta)+position.y*math.cos(octave.teta)
summ = summ + octave.length
h = h + octave.length * mycos (p*(x+octave.shift.x)/(octave.length^1.1))*mycos(p*(y+octave.shift.y)/(octave.length^1.1))
end
end
return h/summ
end
Re: Help with autoplacement for multi level (3D) map
It's exception for spawning area: you have too big chance to drawn in the lake. The form of starting area will be changed in next versions.