Diamond Square | Procedural Generation | Game Development Tutorial

Поделиться
HTML-код
  • Опубликовано: 16 сен 2024

Комментарии • 60

  • @WhiteBoxDev
    @WhiteBoxDev  Год назад +6

    After reaching the 2nd square step at 4:45, I make a handful of manual arithmetic mistakes. I'm sorry about this! Thank you to the people who did the math and commented.
    My solutions of should actually be . Similar situation with the 2nd diamond step at 5:34. Please follow the algorithm as explained and your answers will be correct. Disappointing mistake.

  • @gralcio
    @gralcio 2 года назад +7

    If I remember Tarn's presentations correctly, " in the mid-point" is how DF generates local heightmaps starting with high-level world gen constraints at edges.

  • @Seraph120
    @Seraph120 3 года назад +18

    Keep up the great work. Your style is of explaining is very thorough. That's not something everyone just does or can do right.

  • @Zicrus
    @Zicrus 2 года назад +4

    1:20 I think the 2nd step is called the diamond step, because it creates a diamond formation, and the 3rd step is the square step. Then the name, diamond square, also makes more sense, since the diamond step is before the square step. It is also what it says on wikipedia.

    • @WhiteBoxDev
      @WhiteBoxDev  2 года назад +3

      Definitely up to interpretation. In my mind, the first step makes more sense the "square" because we are pulling data from the four square corner nodes into the center node. The second step pulls data from the four diamond corner nodes into the center node. But yes you are correct, most sources will swap the names. It's a good thing semantics aren't as important as the logic.

  • @prowokator
    @prowokator 3 года назад +10

    Really like how you go through the "code", its great as the concept doesn't get shadowed by the coding language itself. Subbed fo sho!

  • @Sketchaphone
    @Sketchaphone 10 месяцев назад +1

    Thanks for demoing all these different techniques. It's really useful to compare the difference in terrain generation methods for my use cases

    • @WhiteBoxDev
      @WhiteBoxDev  10 месяцев назад

      No problem, they were fun to make.

  • @ninobrouwers1818
    @ninobrouwers1818 3 года назад +5

    Great videos man! you really manage to cut your topic into smaller pieces which you each give a a thorough and in dept explanation.
    What I love, is that your explanations are so thorough that it already gives enough information for me to first try recreating the algorithm without having to look at your coding. And then when something doesn't work in my code I can watch the rest of your video to see what you coded different. Much better then the kind of you tube videos where you just copy over the code and mess with it till it works!!!

  • @_gamma.
    @_gamma. Год назад +3

    All of your tutorials are awesome, wish there were more!

  • @DobinSergei
    @DobinSergei 2 месяца назад +1

    It would be nice to add one rule to algorythm.
    Before all make a mask of bytes, with sizes of map.
    Using on it a diamond sqare algorythm, with height range = 0..1, we get natural looking areas.
    Now, we do default diamond square generation of map. But we using not constant rougness, instead we control it with our premade mask.
    It makes more interesting heights variation. With smaller regions more rough heights variation, and with more steep and smooth plains and hills overall.

  • @MisterRuneex
    @MisterRuneex 3 года назад +1

    Love how you structure your videos. Makes them easy to follow - plus the subjects are very interesting! Keep it up, with your video quality you only need the RUclips algorithm to show one of your videos once on the front page, and your views and subs will skyrocket ;)

  • @aleksandersabak
    @aleksandersabak Год назад +4

    5:11 I did the math myself and it seems like you miscalculated the values. For example average of the corners of the x square is (2 + 4 + 6 + 5)/4 = 4.25, but you show 6. I think this is because instead of dividing by 4 you kept the division by 3 from the previous step, getting 17/3. This seems to also work for other values. Is it right?

    • @WhiteBoxDev
      @WhiteBoxDev  Год назад +1

      Hi from six months in the future. Sorry for not replying back then, must have missed your comment. Yes, you are correct, I made some arithmetic mistakes while doing the calculations manually. I'll post a standalone comment about this. Thank you.

    • @aleksandersabak
      @aleksandersabak Год назад +1

      @@WhiteBoxDev No worries! It was an enlightening video nonetheless, and I enjoyed implementing and playing with the algorithm you presented.

  • @MikeDSutton
    @MikeDSutton 3 года назад +2

    Great video, well explained. One suggestion though is in your demo applications, when changing things like the random scalar value that the map is re-generated with the same seed as the current one. This way the behaviour of the variable can be more easily determined in isolation. This is more like the left click behaviour, which doesn't modify the randomness, and only changes the seed.

  • @thenaturalpeoplesbureau
    @thenaturalpeoplesbureau 3 года назад +2

    in my terrain gen, i made an option to calculate diamondSqr and then use the different colors to either; add, subtract, multiply or divide each other. So one RGB map from DSqr can generate many different options - although the original colormap can also be used. But the best results i get with divide and multiply, nice river flows emerge and cliffs.. Plasma Fractal is the best terrain gen algo in my opinion.

  • @awesomegamedev
    @awesomegamedev 2 года назад +4

    Nice video!
    And the algorithm is very cool and simple to probably fit into one of my future "Game in 10 minute" videos
    Watched this, "Cellular Automata" video, and will be sure to watch the remaining two (and upcoming algorithmic videos:)
    Subscribed!

  • @apaskiewicz
    @apaskiewicz 2 года назад +2

    This is fantastic. Thank you so much for this video.

  • @llpBR
    @llpBR 8 месяцев назад +1

    I was looking for a different algorithm to make my maps. I've created one from my mind and necer thought it was a cellular automata also. This one is way simpler and effective. I'll try and it!

  • @burtenplays
    @burtenplays 3 года назад +1

    I'm having a little issue with there being visible diamond patterns in the generated map but as for that its the closest I've gotten so far and its probably just me rewriting it in java. The code explanation along with the example code helped me out as I had tried learning from other sources and they were just nightmare to understand. I watched your other vids as well and look forward to seeing more.
    *edit
    Never mind, I got it. Had to rewrite it from a potato level vs trying to understand and port code from a different language and it is flawless. This also means I fully understand it something I struggled with for far too long. Thanks again!

    • @WhiteBoxDev
      @WhiteBoxDev  3 года назад +1

      Great, glad you got it to work. Yep, procedural generation algorithms can be difficult to grasp intuitively, so no worries there.

  • @danixadem
    @danixadem 2 года назад +1

    Great video. Please keep posting new videos like that one !!

  • @mikamulperi
    @mikamulperi Год назад +1

    Thank you! Very clear and understandable video.

  • @thatrealguylogan
    @thatrealguylogan 2 года назад +1

    wow, thank you so much for this tutorial and going through the process!

    • @WhiteBoxDev
      @WhiteBoxDev  2 года назад +1

      No problem!

    • @thatrealguylogan
      @thatrealguylogan 2 года назад +1

      @@WhiteBoxDev Hey one question at 4:45 you say we repeat what we did before and get the average again, but when I add 2+4+6+5 and divide by 4 for (x) the average for me was 4.25 instead of 6 as you show, do you know what the problem is that I have missed?

    • @WhiteBoxDev
      @WhiteBoxDev  2 года назад

      @@thatrealguylogan You're correct, it should be 4 instead of 6. I made a mistake there, good catch.

  • @francescocarbone8466
    @francescocarbone8466 Год назад +1

    Best work.

  • @darkfrei2
    @darkfrei2 3 года назад +1

    Many thanks! Very helpful, very easy to understand!

    • @darkfrei2
      @darkfrei2 3 года назад +1

      I've made by myself: ruclips.net/video/2a-RqgjE-Q8/видео.html

    • @WhiteBoxDev
      @WhiteBoxDev  3 года назад +1

      You're welcome! Awesome to see you applied it yourself.

    • @darkfrei2
      @darkfrei2 3 года назад +1

      Another one, with interpolation: ruclips.net/video/yVmUkjOE0j0/видео.html

  • @cazpfitl
    @cazpfitl 2 года назад +1

    pretty cool

  • @Defiler86
    @Defiler86 2 года назад +2

    Great videos, and do enjoy the language agnostic breakdowns.
    But something I don't get in this is height_map_size = 2^n+1. What would n equal, and how would one go about figuring out determining a map of a fixed size? (I may just be missing something, but hoping for a clarification.)

    • @WhiteBoxDev
      @WhiteBoxDev  2 года назад +3

      2^n+1 simply refers to the number of tiles on your grid, in other words your map size. The algorithm requires the map to conform to this. Why? Because of the way it calculates its diamonds and squares, shrinking smaller and smaller as the algorithm continues. It is just how the math checks out.
      N can be any value you want it to be. We can interpret n as the number of diamond-square iterations that are required in order to assign a value to every tile on the map. For example, if n = 2, then we will have 2 diamond steps and 2 square steps. Consequently, the size lengths of this map would be 2^2+1, or 5. In total, our map would then be 5x5, or 25 tiles.

    • @Defiler86
      @Defiler86 2 года назад +1

      @@WhiteBoxDev Thanks for the breakdown on it. The length will always be odd, and makes sense in hindsight. (Been stuck in my head to use even numbers on dimensions.) n is the number of iterations the map will go through, and to insure a determined dimensions of the map just requires a little forward math.
      2^5+1 would be a length of 33 with 5 interations, and produce a map of 1089 tiles (33^2).

  • @sithmaster
    @sithmaster 2 года назад +2

    I really like it! May I ask as an artist how granular this could get? Wondering about resolution size (like lets say create 4k maps), scaling of terrains, height resolution for grayscale (8 bit, 16bit) VS performance. All best.

  • @mattzrsimon
    @mattzrsimon 3 года назад +1

    Very nice video!

  • @Inevitablerizzler
    @Inevitablerizzler 2 года назад

    This is what notch used in his ludumdare game Minicraft

  • @sergodobro2569
    @sergodobro2569 11 месяцев назад +1

    Respect to pseudocode!

  • @wynniechan3366
    @wynniechan3366 6 дней назад

    Trying to interpret this and convert what I understand to GML, as I'm working in Gamemaker... I'm having lots of trouble because I feel like some variables are left out. Start and end are used lots in the for loops, but I have no understanding of what those mean, could you offer some insight?

  • @gingy3778
    @gingy3778 2 года назад +3

    Awesome tutorial! However, may I ask you a question? I’ve got the terrain generating as expected, but I would like to make a map with many continents, a huge world.
    So, how can I generate a map with a smaller scale? As the maps in your video, and the ones I’ve been able to generate are very “close up” on the islands if you know what I mean, zoomed in. Is there a way to reduce the size of the noise to smaller scales? Anyways, thanks!

    • @WhiteBoxDev
      @WhiteBoxDev  2 года назад +1

      Sounds like Fractal Noise is the algorithm you want. It allows for infinite worlds and is easily customizable. See my video here: ruclips.net/video/Z6m7tFztEvw/видео.html

    • @gingy3778
      @gingy3778 2 года назад +2

      @@WhiteBoxDev great thanks!

    • @gingy3778
      @gingy3778 2 года назад +1

      @@WhiteBoxDev as you mention in that video, you need a simplex noise library. I’m using gamemaker, and so having trouble finding an appropriate library. By chance, would you know one which would be suitable?

    • @gingy3778
      @gingy3778 2 года назад +1

      @@WhiteBoxDev I’ve been searching and still am unable to find a proper library.

    • @WhiteBoxDev
      @WhiteBoxDev  2 года назад

      @@gingy3778 I don't know much about Game Maker, but I see it maybe uses its own scripting language? If that's the case, you could ask in the Game Maker forums or Discord if anybody knows of a library for Perlin Noise. If not, you could try porting an existing implementation over to Game Maker's language.

  • @hatac
    @hatac 9 месяцев назад

    What happens if the four corner values are the same? I presume you get a flat sea bed, 'swamp', plains or plateau. This gives a uniform sea level. How would you get a highland lake or pond? I presume that would require another algorithm with added passes.

  • @theb1524
    @theb1524 3 года назад +1

    please remove the empty English transcript so we can at least use auto captions in English. Great Video btw awesome work!

    • @WhiteBoxDev
      @WhiteBoxDev  3 года назад

      Auto captions weren't an issue for my other videos, but for some reason they're not showing up here. I didn't add any extra transcripts, so not sure what's going on. I'll look into it a little more.

  • @aazimmermann
    @aazimmermann 2 года назад

    Any ideas on how we can tile the tile segments generated by the algorithm where each tile is unique?

  • @GaryMcwr
    @GaryMcwr 3 года назад

    Is there a reason why the only subtitles option for the video is Korean?

  • @maxdukhovskoy1406
    @maxdukhovskoy1406 2 года назад

    7:22 if height_map_size is 5, then how would height_map_size - 1 = 3?

    • @WhiteBoxDev
      @WhiteBoxDev  2 года назад

      I was speaking to the current iteration of the algorithm shown in the image. It is already on the second step. On the first step, you are correct that chunk_size will be 5 - 1 = 4.

  • @jamesmunroe6558
    @jamesmunroe6558 Год назад +1

    You lost me at 5:23. "The math for calculating each of these values is the exact same as before." Only with our new squares, we have the average of the corner values for x as (2+4+6+5)/4 = 17/4 + R, for y as (4+8+5+4)/4 = 21/4 + R, for z as (6+5+5+4)/4 = 20/4 = 5 + R, and for w as (5+4+4+1)/4 = 14/4 = 7/2 + R. Am I missing something?

    • @WhiteBoxDev
      @WhiteBoxDev  Год назад +1

      Yes, you are correct, I made some arithmetic mistakes while doing the calculations manually. I'll post a standalone comment about this. Thank you.

    • @jamesmunroe6558
      @jamesmunroe6558 Год назад +1

      @@WhiteBoxDev OK thanks, I'm glad I wasn't off the beam - I was worried I'd messed up. I'll stay tuned for your comment so I can complete the exercise.

  • @turkeyphant
    @turkeyphant 24 дня назад

    3:44 makes no sense. where are these diamonds?!