Procedural world generation using LPC assets
Hi everyone!
At the end of 2018, I discovered the LPC assets (I am a bit late ...) and was totally fond of them and thought they were perfect for doing procedural generation.
For two months, I have more free time and so I have started to create a procedural world generator using these assets. Now, that I start to have some results, I want to share it with you.
The first step was to create a map generator:
Then, I used the LPC terrains tileset to transform the map into a world made of tiles:
The next step was to also create the rivers and the roads. Here are images with bridges (there are still some minor issues):
Finally, this week I have worked on filling the biomes with trees and other decorations:
As you can see, the awesome work of bluecarrot16 is a source of inspiration.
If you want more technical details on how I generate all that, I have written weekly devlogs and the series starts here.
The next step is to write a dungeon/cave generator. And after that, a city generator, a building generator, a character generator, etc. until I have a full RPG!
I hope you like it and I thank deeply all the artists of the OGA community!
If you have any question or comment, feel free!
This looks so cool tbh!
Ooooh. I'm an art person, I don't understand the programming, but I do understand that it's pretty cool. Can you alter the tree generation to get them to clump together the way real trees tend to do?
Neat indeed!
I think with clumping trees you'd ideally first generate some paths and then use trees to fill up the empty spots. Maybe leave one or two spots unfilled for clearings. This will ensure players will be able to navigate forests. You'd also want to make sure there's some areas of interest, such as the clearings, or particularly funny looking trees to make it easier to navigate.
/me runs off to read devlogs.
Thanks for the kind feedback!
With the technique I use to place the trees, it is possible to vary the density using a grayscale texture (e.g. Perlin noise). I will surely use that to simulate clumping.
There will be areas of interets too. For now, I have planned to do ruins, graveyards, dungeon/mine/cave entrances, camps, and inns.
I will try to update this thread as soon as I have something interesting to show.
I've been working on something similar for a while too; I'm itching for summer holidays to start so I have time to go back to it.
For placing trees I tend to just scatter a bunch of trees around and give it a pass with cellular automata. Works well. Note though that I determine the biome type (based on a combination of elevation and, again, cellular automata) and then place trees, rather than placing trees and figuring out where the forests are later.
EDIT: forgot to say, working with cliffs is a right pain in the rear. The code keeps finding new and interesting ways to break by needing non-existent corner transitions. I still need waterfalls for east/west and north directions too.
map.png 4.2 Mb [12 download(s)]
Nice result!
I would like to add cliffs and mountains too but I am not sure how to do that correctly.
Is this the final scale or you will generate larger worlds later?
Wow, this is really neat you guys!! pvigier, I enjoyed reading your dev diaries and I can't wait to see where this goes.
I agree with Sharm that the trees look better when clumped. Even if all the trees are the same, like in Evert's example, it looks a little more natural. This also reminds me I would like to revisit my trees repack, because some of the trees are really stylistically just way too different. I started tweaking Skorpio's tree (the one in Evert's example) a while ago to make it look more like Sharm's tree from the base assets, but never got back to it.
Great work with the cliffs, Evert. I feel your pain... even putting together the mountains set, I realized how many combinations there are and how kind of non-intuitive it is. I'm not sure how to make it simpler though without drastically changing the art style. East/west/north waterfalls shouldn't be too hard to hack together from the terrain and mountain tiles, since most of the waterfall itself will be obscured by the cliff.
Both examples remind me is that we could use some more filler/variant types for the ground. The simple, flat terrain shapes of the LPC base assets are excellent when there's enough other visual interest in the scene---they are easy to parse and they let other things pop. But when they're just in a big open space by themselves, they look really barren and repetitive. I've been working on a "grassland" or "savanna" set for a while that operates on the same principle as the bricks---to be overlayed on top of the terrain tiles on a separate layer; you can see a few diferent ideas for that in the example I attached (uses tiles from Sharm, Hyptosis, Jetrel, Daniel Cook, and Zabin). Maybe something like that could be incorporated as a "sub-biome," or mapped to an intermediate level of the elevation profile in pviger's example.
Finally, tou guys should also hook up with macmanmatty; he's interested in procedurally generating trees, and had me draw some leaves to be assembled into trees and stuck on different trunks. The results turned out better than I expected (see the apple/peach/walnut/oak and maple examples), although I'm not sure they'll ultimately really look consistent with the LPC style, since those trees don't show every single leaf.
Anyway, didn't mean to hijack your threat and turn it into my own personal WIP showcase :p I'll be watching to see how things develop!
tree.png 5.9 Kb [3 download(s)]
savanna.png 158.4 Kb [5 download(s)]
leaves-demo-apple-peach-walnut-oak.png 8.8 Kb [4 download(s)]
trunk1-maple.png 2.8 Kb [2 download(s)]
Looks tiny, doesn't it? The feel for the game that I'm going for is Legend of Zelda: A Link to the Past. The overworld in A Link to the Past is 16x16 screens. The original Legend of Zelda was 16x8. Link's Awakening is also 16x16. None of those worlds feel very small, so beginning with something similar seemed like a reasonable thing to do. I believe Lenna's Inception also uses a 16x16 screen overworld, but I haven't checked in a while.
Of course, the thing with those Zelda games is that they have very intricately designed worlds with gated progression and winding paths that make the world feel larger than it is. For instance, to go from your house to Kakariko Village in A Link t the Past you have to take a detour to the south and walk around to approach the village from the south, or slip past Hyrule Castle and approach from the north. A Link between Worlds added a short-cut to the west of Hyrule Castle that takes you directly to the smithy, and it makes the world feel smaller as a result. I don't know if that level of crafted detail is something that can be accomplished with procedural generation (in principle, sure, but in practice it may be hard for a one-person dev team with a regular job). We'll see. At any rate, I do plan to enforce a rule that every screen has to have "something" of interest on it, so the world doesn't feel empty.
I got fed up with getting the cliffs to work correctly though, and gave it a bit of a rest last year. I've been tweaking the dungeon generation and combat system in the mean time, but both need work. I've been checking out Unexplored (information about the game anyway; the art style doesn't appeal to me, so I haven't played it), which has a very neat system for generating dungeons (using loops rather than the typical roguelike generators) that I want to do something with.
In the end of the day, this is a procedural world. Making it larger is trivial, and I might even make that an option so the player can decide if they want a fast game or a sprawling epic.
I think the solution to massive, repetitive open areas is just to not have any, and fill that space up with interesting stuff. So for that, the LPC base assets work fine (but more variation is great - also helps to make different areas in the game more distinct and memorable).
I have a few more tree variations to throw in, but I'm deliberately limiting it to three or so.
The major pain I have with the cliffs is that they're assymmetric: they extend two extra tiles southward cmpared to any other direction. Part of the issue, of course, is that I'm trying to do a Zelda-like perspective with art that has a more Final Fantasy perspective. Another part of the issue is that I don't have all my mountains pushed off to the northern edge of the map. Things get really complicated if the generator decides that terrain should drop down two levels. In theory the cliffs should tile properly. In practice, a procedural generator will find interesting corner cases that break things. I've been plugging those up, but new ones just take their place, so I'm trying to work out something that is more robust. I keep going back and forth on keeping the LPC base mountains or trying to find something else. I'd prefer to keep the LPC stuff.
The problem with the waterfalls is exactly that they end up being obscured by the ciffs: it's hard to tell that it's there and make it look good at the same time. Or I just suck at doing the pixel art for it, which is a distinct possibility. Games such as Zelda, Secret of Mana and Chrono Trigger avoid the issue by only putting waterfalls on south-facing cliffs.
Thanks bluecarrot16, it means a lot coming from you! It is your packs that inspired my project.
Oh yes, the rework of the tree is nice, it fits well the LPC style. I use it too, as oak in my generator. If one day, you finish it, let me know.
Yeah, I am thinking about sub-biomes. It is not a top priority but it would definitely make the world more interesting
That's clever to generate the trees like that, especially for fruit trees. That's interesting, I may give it a try.
@Evert Yes, it is amazing how Zelda games fell gigantic while they are quite small in reality. It is funny that despite appearances, we are not trying to do something similar at all. I am planning to generate large worlds like 3000x3000 tiles.
I look forward to seeing the results of your dungeon generator. I am currently creating mine, more in the roguelike tradition. By the way, have you written up some devlogs?
I haven't written up any devlogs, no. I thought about starting something like that up, but couldn't find an immediately obvious venue for it. I also considered that if I have time to do something on the game, I would rather spend it on the game itself rather than writing about it. Sharing stuff is fun though, so I keep half making up my mind to write about it anyway, then postpone it. I do have extensive notes on everything though, so I could easily start something up.
The dungeon generator I have now also borrows from roguelike generators, as well as the various entries on https://bytten-studio.com/devlog//tags/#lennasinception-ref. The problem is, it doesn't have the right feel for what I want (which is Zelda-like). Treasure and item placement on the map is just too predictable. Anyway, playing around with different algorithms and seeing what comes out of it is half the fun of procedural content generation anyway. :)
@Evert If you eventually write something one day, I will be glad to read you! Thanks for the link, it seems really interesting!
Since last time, I have worked on dungeon and cave generation.
Here is an animation describing the steps of the generation:
Then I worked on generating tiles using [LPC] Mountains tileset from the output of the generator:
If you are interested by the details, I have written two new devlogs: here and there.
I also started working on brick walls but it is not quite ready.
Hope you like it!
@pvgier: That's pretty great. Would your algorithm allow for occasional ellipsoid room generation inside the cells as well as the typical rectangle rooms? The final result does a good job of looking very organic, I just wonder if starting with a few rounded "definitively alive" components may contribute even more to the cave-look.
(P.S. I refer to axis-aligned elipsoids, specifically)
--Medicine Storm
Thanks! :)
For now it does not. But it is definitely a good idea! I have already thought about it and I agree with you, it should make the rooms even more organic.
I did not implemented that yet because it is slightly trickier to create the corridor between two ellipses than between two boxes. But in a further version, I will certainly do it.
I don't know how your code is arranged, so I don't know if this will work for you, but your devblog has inspired me to ensure my own procedurally generated dungeons are as interesting as possible.
I imagine the corridors between rectangles are based on vertical-to-vertical border-of-box or horizontal-to-horizontal border. If the corridors are instead calculated based on center-vertical axis to center-vertical axis (or horizontal-center to horizontal-center) the algorithm would be able to operate mostly unchanged, but still work just as well with elliptical rooms.
Are you willing to share your algorithm code? I doubt it's in a language I typically use, but it seems abstractable enough to be adapted to whatever language. If not, no biggie; I'm sure I can take the concept you've outlined and write my own version. :)
--Medicine Storm
Indeed, I am currently doing corridors border to border. Yes, if we make the corridors from vertical-center to vertical-center, there is nothing to change as far as the corridors are concerned but then corridors and rooms overlap. In my internal representation of the dungeon, I would rather not have corridors intersecting rooms. In any case, it is not a big issue: computing the intersection between a vertical/horizontal line and an axis-aligned ellipsis is easy.
Nice animation by the way!
I plan on open-sourcing the code when everything will be ready and polished but for now I have not shared it yet. It is in C++ and uses my framework. As it is, I am not sure, it would be really helpful. I think it would be faster to reimplement it from scratch using the devlogs but if you really want to see the code, I can send it to you.
If you have any question, let me know.
I look forward to seeing your dungeons!
Wow, this is really inspiring!
what engine can you implement this to?
and why do you use the whittaker diagram?
Thank you very much!
I use a custom engine that I am making using C++, SFML and OpenGL.
I use the Whittaker diagram to determine biomes from temperatures and precipitations.
I am still working on this project. But I don't have much to show since I am currently working on low-level parts of the game engine.
I worked on my graphics engine and started to implemented a light system. Here are some screenshots:
I also implemented a day-night cycle, I took inspiration from the submission of Casper Nilsson:
I am still publishing a devlog each week on my blog if you are interested by the details!
light_cave.gif 2.3 Mb [1 download(s)]
day_night_cycle.gif 3.9 Mb [1 download(s)]
Quick update of this project.
I greatly improved the cave generator and I implemented the suggestion of MedicineStorm of using ellipses:
There is also now something looking like a game with a crude interface and we can move a character in the world and attack monsters:
You can find more info and in-game videos on my Twitter account or in the devlogs.
Have a nice evening! :)
Looking great!
Check out this lib for random content generation.
https://github.com/mxgmn/WaveFunctionCollapse
(i did not make this lib, but i am using it)