Layer-Based Procedural Generation for Infinite Worlds

  Рет қаралды 101,829

runevision

runevision

10 жыл бұрын

How can complex procedural generation work for infinite worlds in cases where data needs to have access to surrounding data? In this video I describe a layer-based approach to this problem.
For the VR game I'm currently working on, check out:
store.steampowered.com/app/58...

Пікірлер: 74
@madmenyo
@madmenyo 5 жыл бұрын
This is a awesome procedural pattern! I had the idea of a map where towns need to be connected by roads, this is excellent for it. I hope I can create a similar system that is efficient enough for a game since I have a lot more complexity in mind, not all cells can and will hold a city and roads connecting them will need pathfinding to make it realistic.
@PaulMielcarz
@PaulMielcarz 9 жыл бұрын
Thanks for sharing! This kind of systems are fascinating. Great job! I hope your game becomes a hit! :)
@osten222312
@osten222312 Жыл бұрын
Thank you so much! This is great knowledge and useful inspiration all these years later
@tannervandewalle4275
@tannervandewalle4275 7 жыл бұрын
This is awesome! Can't wait to have some time to implement something like this :D
@eduugr
@eduugr 7 жыл бұрын
This is very cool and inspiring, thanks for sharing !
@iforce2d
@iforce2d 7 жыл бұрын
Some good ideas here. Great way to spread the calculation load.
@bitbutter
@bitbutter 10 жыл бұрын
Thanks for this. Seems like a powerful approach.
@nanthakr8378
@nanthakr8378 8 жыл бұрын
Very very thank you for the article on gamasutra
@runevision
@runevision 10 жыл бұрын
Well depending on the distance it might not be feasible to generate everything in between the two locations. One approach would be to unload everything at the old location before loading from scratch in the new one. Another approach would be to have a separate instance of the grid that can load in the background at the new location, and then swap them when ready.
@StellarMirage
@StellarMirage Жыл бұрын
After 8 years of this video being published, I am watching it and it still feels great. Those few words at first got the potential of the whole video. The pattern of the green areas gave me an idea of how to generate settlements and connect them via roads.
@ashwanishahrawat4607
@ashwanishahrawat4607 3 жыл бұрын
Thank you very much! It sparked many things in my skull.
@RobertMilesAI
@RobertMilesAI 5 жыл бұрын
If you're in an area and then you travel away far enough that it unloads, and then come back, is it the same as the last time you were there or is it generated again? Is there some kind of location-based seed so it stays the same?
@runevision
@runevision 5 жыл бұрын
Yes it's the same due to seeds based on coordinates.
@janforberger675
@janforberger675 3 жыл бұрын
I really love this method. I am currently working on a procedural 3D cave generator where I want the caves to be interconnected. My idea is to extend this to the third dimension.
@GaryMcKinnonUFO
@GaryMcKinnonUFO 8 жыл бұрын
Good stuff, thanks for sharing.
@runevision
@runevision 10 жыл бұрын
Good question! It's one of the issues I haven't solved yet.
@muzboz
@muzboz 3 ай бұрын
Very interesting. Cool stuff.
@runevision
@runevision 3 ай бұрын
Thanks! Old video, but sometime this year I'll be releasing this framework as open source and make more in-depth materials about it.
@bitbutter
@bitbutter 9 жыл бұрын
I'm trying to implement something similar but could use some hints on the step of spacing out the points. I was initially thinking of using Lloyd relaxation, but am not quite sure how to implement it. Are you limiting the 'spacing out' operation to affect only layer 1 cells (and not higher level ones)? In the designs that exist in my head I keep running into the problem that the adjusted positions of the points would vary according to exactly where the grid was at the moment they were calculated. Could you say some more about how you handled this?
@runevision
@runevision 9 жыл бұрын
I'm not quite sure I understand the question. It works like this: As part of upgrading cell A from layer 0 to layer 1, it will look at its own initial points as well as the initial points of the 8 neighbor cells. It then calculates adjusted points for itself. These do not replace the initial points; the initial points are still kept around. If later some neighbor cell to A (let's call it B) need to be upgraded to level 1 as well, it will look at the initial points of itself and its neighbors. Note that even though A had adjusted points calculated, B will still only look at the initial points of A, not the adjusted ones. This avoids non-deterministic calculations that would be different depending on the order different cells are upgraded in. It also means all cells must keep all data calculated at each level.
@bitbutter
@bitbutter 9 жыл бұрын
runevision Thanks that's helpful.
@jrkirby93
@jrkirby93 10 жыл бұрын
would it be possible to get better performance by using a hexagonal grid?
@owensoft
@owensoft 10 жыл бұрын
whats the fastest you can move through the space? if its pretty fast you could just do a loop( postion ++ ){ generate(position) }; until you reach where the players wants to be. As long as the generation code is fast it should not be a problem to do that in the a split second - especially when there is no need to render anything.
@colin_hart
@colin_hart 6 жыл бұрын
What is the name of the triangulation method you mention at 6:53? I can't make it out in the video. Thanks!
@runevision
@runevision 6 жыл бұрын
en.wikipedia.org/wiki/Delaunay_triangulation
@arcaneingenuity2091
@arcaneingenuity2091 8 жыл бұрын
+runevision What are you using for rendering? I take it this is Unity, but is this all wireframe drawing within the editor?
@runevision
@runevision 8 жыл бұрын
+Arcane Ingenuity Yeah it's Unity and within the editor. I'm using the GL class for drawing the lines.
@astrixx
@astrixx 8 жыл бұрын
reminds of geoclipmapping used for LOD in terrain generation
@Andrew90046zero
@Andrew90046zero 3 жыл бұрын
How did you do your triangulation? Recently I have been trying to make 2D procedural caves and all I was doing was generating 1 random point for each grid and then picking a random neighbor to connect to. But your triangulation seems to have more interesting connections than mine did.
@user-tz8eg6up5s
@user-tz8eg6up5s Жыл бұрын
delaunay triangulation method could help
@DoubleBob
@DoubleBob 8 жыл бұрын
Which algorithm do you use to relax the points in layer 1? (no points directly next to each other)
@runevision
@runevision 8 жыл бұрын
+FernestHall For every point in the current chunk I calculate an adjustment vector. Then the new point is the old point plus the that vector. The vector is calculated by comparing the point will all the other points in this chunk and neighboring chunks. For each pair I calculate the distance between them. I have a max distance beyond which there is no effect. If smaller than the max dist, the point is pushed away from the other point by a distance that is 0.4 times the max distance if the points are practically overlapping, and 0 if they are max distance away from each other. The push distance is a linear interpolation between those. The point is not pushed right away but the push vector added to the adjustment vector. There is no order dependency this way, neither for the order of points considered or the order of chunks calculated.
@owensoft
@owensoft 10 жыл бұрын
I think you will have to fast walk ( in the background ) to the location in a straight line , generating everything so that the user ends up the same place.
@SpicyMelonYT
@SpicyMelonYT 2 жыл бұрын
Ok so it works like a shader then!. At first I was confused thinking you were baking in the layers into the starting point positions but then when you moved the screen and the points "delayered" back into their original positions, i realized that it works additively on the original "geometry". I really like this idea and will use the concept in my own work. OH SHIT this is from 2013...damn. I am so late to this lol!
@daddy484
@daddy484 8 жыл бұрын
This is really cool. Can you elaborate on how you manage to generate all the dots though? I've been looking to find something like this for a while.
@runevision
@runevision 8 жыл бұрын
+daddy484 The initial points are generated as random number produced by a hash function. See my article here for more details on random numbers and hash functions: www.gamasutra.com/blogs/RuneSkovboJohansen/20150105/233505/A_Primer_on_Repeatable_Random_Numbers.php
@daddy484
@daddy484 8 жыл бұрын
I'll take a look, thank you very much.
@owensoft
@owensoft 10 жыл бұрын
Very interesting. How does this technique behave if you try to warp from one area to the next?
@publicalias8172
@publicalias8172 2 жыл бұрын
nearly 10 years later. Hi
@runevision
@runevision 10 жыл бұрын
Ah, like that. There might be a slightly better constant, but I don't think the extra complexity in the code everywhere would be worth it. It might even eat away some or all of the gain.
@jrkirby93
@jrkirby93 10 жыл бұрын
I didn't even realize you replied, youtube moved the inbox, I guess. It would give better performance because there are less cells touching each center node. I looked it up, and even though it's still asymtotically O(N^2), it should have a better constant. (N is the number of levels)
@ColinPaddock
@ColinPaddock 2 жыл бұрын
I’d assume this could be adapted fairly easily to 3D.
@runevision
@runevision 2 жыл бұрын
Yeah the principles are independent from the number of dimensions.
@egorbashinsky187
@egorbashinsky187 5 жыл бұрын
Love the result, but it's so hard to dig out some sens in what he says.
@WindBendsSteel
@WindBendsSteel 4 жыл бұрын
it goes on, and on, and on! Heaven and Hell!
@dominikseifert4983
@dominikseifert4983 9 жыл бұрын
For reference, the connections are generated by Delaunay Triangulation: stackoverflow.com/questions/7309538/efficient-delaunay-triangulation
@runevision
@runevision 9 жыл бұрын
Dominik Seifert Actually, while I did try out Delaunay Triangulation for this, but ended up with a simpler custom solution.
@dominikseifert4983
@dominikseifert4983 9 жыл бұрын
You said it in the video. Can you comment on it some more? Maybe even post some code or pseudocode?
@runevision
@runevision 9 жыл бұрын
Dominik Seifert Ah, well I changed it later anyway. Now it's just: 1) A minimum spanning tree for the points inside the current cell. 2) For each of the neighbor cells: - The shortest connection possible between a point in the current cell and in the neighbor cell.
@dominikseifert4983
@dominikseifert4983 9 жыл бұрын
Do you just bruteforce it? (Seeing how you have max 3 pts/cell, that seems rather feasible)
@runevision
@runevision 9 жыл бұрын
Dominik Seifert Yep, no reason to try something more clever for this small amount of points.
10 жыл бұрын
Why no source code?
@FireChronos
@FireChronos 8 жыл бұрын
How does the seed work? Obviously you wouldn't want new points if backtracking.
@runevision
@runevision 8 жыл бұрын
Using a hash function. For more info, see this article: www.gamasutra.com/blogs/RuneSkovboJohansen/20150105/233505/A_Primer_on_Repeatable_Random_Numbers.php
@runevision
@runevision 5 жыл бұрын
@@martian17 No, that's exactly the issue that the layer-based approach solves. For each cell you have the points before relaxation and after relaxation. Calculation of relaxed points for a cell requires the unrelaxed points for that cell plus its neighbors. But the relaxed points never feed into other calculations of relaxation. The cell keeps the unrelaxed points also after calculating the relaxed points. The relaxed points is new data, not modification of existing data. It's a one-way dependency, and works deterministically the same way for a given cell every time.
@orkunsevengil336
@orkunsevengil336 6 жыл бұрын
Good resource to reverse engineer eve online?
@madmenyo
@madmenyo 5 жыл бұрын
No, eve online has a fixed map. Perhaps first generated and then altered to make it more interesting with dead ends and choke points. But sure you can create something similar with this in an infinite form, but the more detail you need the more of these chunks you need to have loaded.
@gara5318
@gara5318 4 жыл бұрын
All interconnected by portals and teleportation booths.
@MorneBooysen
@MorneBooysen 8 жыл бұрын
where is the game you made with this?
@runevision
@runevision 10 жыл бұрын
It doesn't scale. Two positions could be billions of grid cells from each other. Besides, the generation is not that fast. You can see it lagging behind in the video when scrolling fast.
@angelikmayhem
@angelikmayhem 10 жыл бұрын
Let me help you all out: "Let's take it from the beginning" can be found at 3:52. Up until that point, he just stammers on and on again about what "layers" are.
@ibiixie
@ibiixie 8 жыл бұрын
I'd love to see notch explaining how he did his procedural generation... Probably won't happen though :'[
@ibiixie
@ibiixie 8 жыл бұрын
***** Where can I find the minecraft source code?
@lewisb8634
@lewisb8634 8 жыл бұрын
+BiiXteR Gaming Erm, you can't! Notch has written a blog about the terrain generation in Minecraft though - no source code obviously, but he explains very well. Search for "The Word of Notch" and his blog. You'll find it at the bottom of all his other blogs! :)
@ibiixie
@ibiixie 8 жыл бұрын
Lewis B Yes I found that after I wrote this comment, however he never made more parts of it :(
@Asrashas
@Asrashas 6 жыл бұрын
I'd much rather know the arcane secrets Toady One had to unravel to power the procedural generation in Dwarf Fortress.
@runevision
@runevision 10 жыл бұрын
I don't see why that would give better performance.
@JayLooney
@JayLooney 9 жыл бұрын
You should be able to feed the algorithm some coordinates so you just immediately generate the data there instead of generating all the data in between.
@pureay2700
@pureay2700 3 жыл бұрын
Wait did someone copy your game
@runevision
@runevision 3 жыл бұрын
I'm not sure what you're referring to?
@pureay2700
@pureay2700 3 жыл бұрын
Nvm, i remember seeing tour game on a vr newsday.
@MuammarThangkhiew
@MuammarThangkhiew 6 жыл бұрын
Intelligence 100 Charisma -1000
@osirys
@osirys 8 жыл бұрын
eh
How to turn a few Numbers into Worlds (Fractal Perlin Noise)
15:24
The Taylor Series
Рет қаралды 186 М.
Cellular Automata | Procedural Generation | Game Development Tutorial
15:22
Incredible magic 🤯✨
00:53
America's Got Talent
Рет қаралды 54 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 16 МЛН
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 32 МЛН
Better Mountain Generators That Aren't Perlin Noise or Erosion
18:09
Josh's Channel
Рет қаралды 315 М.
EPC2018 - Oskar Stalberg - Wave Function Collapse in Bad North
37:41
Minecraft terrain generation in a nutshell
25:49
Henrik Kniberg
Рет қаралды 148 М.
A CHASM of Mediocrity - Procedurally Generated Metroidvanias
20:34
ingeniousclown Gaming
Рет қаралды 523 М.
Procedural Generation: Programming The Universe
41:57
javidx9
Рет қаралды 203 М.
Procedural Level Design in Eldritch
50:14
GDC
Рет қаралды 37 М.
That Other Kind Of Game - Story Generators
15:28
BuffaTwo
Рет қаралды 295 М.
River Based Terrain Generation - Sapiens Devlog 36
16:25
Dave Frampton
Рет қаралды 83 М.
Clicks чехол-клавиатура для iPhone ⌨️
0:59
Собери ПК и Получи 10,000₽
1:00
build monsters
Рет қаралды 2,3 МЛН
Как слушать музыку с помощью чека?
0:36
Самый дорогой кабель Apple
0:37
Romancev768
Рет қаралды 309 М.