1

I would like to proceduraly generate 2D caves. I already tried out using some 1D simplex noise to determine the terrain of the floor, which is basically everything you can change in a sidescroller, but it turned out rather unimpressive.

I would like to have an interesting terrain for my cave/dungeon and if possible some alternative paths.

I couldn't come up with any ideas for this kind of terrain and I also could not find any promising ways to do this kind of stuff on the internet.

veqa
  • 57
  • 9
  • 1
    I'll refer you to https://gamedev.stackexchange.com/ start by a search there. For instance, see [2D Simplex Smooth Cave Generation](https://gamedev.stackexchange.com/q/101905/10408). If you don't find what you are looking for, try asking there. That site is better suited for this kind of questions. – Theraot Jan 14 '21 at 06:32
  • @Theraot Thanks. For now i got a solution with which i am more or less satisfied but I will look there if I have any further questions. – veqa Jan 14 '21 at 08:06

2 Answers2

3

Assuming you've tried something like abs(simplex) > 0.1 ? nocave : cave, maybe the problem you're running into is that it's too connected, and that there are no dead-ends anywhere. You could extend this by doing the following simplex1*simplex1 > threshold(simplex2) where threshold(t)=a*t/(t+b) where a roughly controls the max threshold (cave opening size) and b roughly controls how much of the underground is caves vs not. The function looks like this, and the fact that it quickly rushes to zero is supposed to make dead ends look more rounded and less pointy. Working with the squared noise value is also for this purpose.

KdotJPG
  • 811
  • 4
  • 6
  • Thanks for the answer i will definetly give this a try within this week. – veqa Jan 13 '21 at 16:24
  • np! Also edited post to fix a slight mistake with which side of the conditional the caves should be generated on. And also I should clarify that this uses 2D simplex noise - I realized you were using 1D! Try the first technique, then if that isn't enough then try the second. Both using 2D noise. – KdotJPG Jan 13 '21 at 16:40
  • If you see diagonal bias, or unnecessarily straight parts, then you can try my OpenSimplex2S here with the "XBeforeY" evaluator. That should resolve both issues. https://github.com/KdotJPG/OpenSimplex2/blob/master/java/OpenSimplex2S.java – KdotJPG Jan 13 '21 at 16:40
  • @KdptJPG I don't know if i will be able to use your Java code in Godot but I will consider searching for something similar in GDScript if it will help improve the generation. Thanks. – veqa Jan 13 '21 at 17:20
  • also i will propably try to make a version which uses polygons instead of Tilemaps just to see how it will effect the looks and playability because the blocks really limit the options for cave generation because of limited movement. I never used polygons, or whatever you should use for something like this, so i'll propapbly need a day to get into though. – veqa Jan 13 '21 at 17:30
  • 1
    Oh, if you're using Godot, then you can use the built-in OpenSimplexNoise module. Its 2D function is almost as high quality as OpenSimplex2S, and if you want the "XBeforeY" equivalent to reduce diagonal bias, then you can just do `eval(y + x, y - x)`. That part is optional, just worth trying in case you see an improvement. – KdotJPG Jan 13 '21 at 23:47
1

Have you tried Perlin Noise? Seems to be the standard way of doing this sort of thing.

Danny
  • 354
  • 3
  • 13
  • I tried perlin noise and I have to say that for realistic overground terrain both simplex and perlin noise look really good and practical. For a cave (which i forgot to mention is build out of blocks) however this looks rather uninteresting and gets pretty hard to navigate. **I came up with another idea of just placing one block after another with certain patterns having certain propabilities, which are determined based on the blocks placed before.** – veqa Jan 09 '21 at 16:29
  • Simplex is actually the successor to Perlin. Good simplex implementations remove cardinal axis bias, and reduce visible grid bias overall. One issue could be the smaller kernel size leading to straight segments in single octave noise, but that's resolved by using multiple octaves in fBm, or by using a "large kernel" type simplex such as OpenSimplex2S which I've put out there. I think OP's issue relates to finding ways to use the noise values, or finding a different technique entirely. – KdotJPG Jan 13 '21 at 13:06