Diamond Square | Procedural Generation | Game Development Tutorial

  Рет қаралды 27,576

White Box Dev

White Box Dev

Күн бұрын

Пікірлер: 62
@WhiteBoxDev
@WhiteBoxDev Жыл бұрын
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.
@Seraph120
@Seraph120 4 жыл бұрын
Keep up the great work. Your style is of explaining is very thorough. That's not something everyone just does or can do right.
@prowokator
@prowokator 3 жыл бұрын
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!
@Zicrus
@Zicrus 2 жыл бұрын
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 жыл бұрын
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.
@Sketchaphone
@Sketchaphone Жыл бұрын
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 Жыл бұрын
No problem, they were fun to make.
@user-og6hl6lv7p
@user-og6hl6lv7p Ай бұрын
Thanks for the tutorial. I spent the weekend implementing this into my own project and managed to get it working. However it wasn't so simple just drawing the height map points. The height map points must be normalized for the height map to be coloured correctly, otherwise it ends up looking like bismuth. For anyone who is curious, you need to grab the min and max values of the height map points (v_max and v_min), which can be calculated in during the diamond step loop. Before you pass the height map points to the renderer, each height map value must be normalized: float v_range = v_max - v_min ... float value = (height_map[x][y] - v_min) / v_range
@gralcio
@gralcio 2 жыл бұрын
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.
@_gamma.
@_gamma. 2 жыл бұрын
All of your tutorials are awesome, wish there were more!
@ninobrouwers1818
@ninobrouwers1818 4 жыл бұрын
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!!!
@WhiteBoxDev
@WhiteBoxDev 4 жыл бұрын
Awesome, good to hear!
@MisterRuneex
@MisterRuneex 3 жыл бұрын
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 KZbin algorithm to show one of your videos once on the front page, and your views and subs will skyrocket ;)
@awesomegamedev
@awesomegamedev 3 жыл бұрын
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!
@aleksandersabak
@aleksandersabak Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@WhiteBoxDev No worries! It was an enlightening video nonetheless, and I enjoyed implementing and playing with the algorithm you presented.
@MikeDSutton
@MikeDSutton 3 жыл бұрын
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.
@apaskiewicz
@apaskiewicz 2 жыл бұрын
This is fantastic. Thank you so much for this video.
@mikamulperi
@mikamulperi Жыл бұрын
Thank you! Very clear and understandable video.
@thatrealguylogan
@thatrealguylogan 3 жыл бұрын
wow, thank you so much for this tutorial and going through the process!
@WhiteBoxDev
@WhiteBoxDev 3 жыл бұрын
No problem!
@thatrealguylogan
@thatrealguylogan 3 жыл бұрын
@@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 3 жыл бұрын
@@thatrealguylogan You're correct, it should be 4 instead of 6. I made a mistake there, good catch.
@danixadem
@danixadem 3 жыл бұрын
Great video. Please keep posting new videos like that one !!
@thenaturalpeoplesbureau
@thenaturalpeoplesbureau 3 жыл бұрын
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.
@darkfrei2
@darkfrei2 3 жыл бұрын
Many thanks! Very helpful, very easy to understand!
@darkfrei2
@darkfrei2 3 жыл бұрын
I've made by myself: kzbin.info/www/bejne/aJKQg6Sdn6pgh5o
@WhiteBoxDev
@WhiteBoxDev 3 жыл бұрын
You're welcome! Awesome to see you applied it yourself.
@darkfrei2
@darkfrei2 3 жыл бұрын
Another one, with interpolation: kzbin.info/www/bejne/r4fQhp6ghKpjoJI
@burtenplays
@burtenplays 3 жыл бұрын
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 жыл бұрын
Great, glad you got it to work. Yep, procedural generation algorithms can be difficult to grasp intuitively, so no worries there.
@llpBR
@llpBR Жыл бұрын
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!
@Defiler86
@Defiler86 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 жыл бұрын
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 жыл бұрын
@@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 3 жыл бұрын
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.
@BootziePootzie
@BootziePootzie 2 жыл бұрын
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 жыл бұрын
Sounds like Fractal Noise is the algorithm you want. It allows for infinite worlds and is easily customizable. See my video here: kzbin.info/www/bejne/kGfQaKd8r9l4rNk
@BootziePootzie
@BootziePootzie 2 жыл бұрын
@@WhiteBoxDev great thanks!
@BootziePootzie
@BootziePootzie 2 жыл бұрын
@@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?
@BootziePootzie
@BootziePootzie 2 жыл бұрын
@@WhiteBoxDev I’ve been searching and still am unable to find a proper library.
@WhiteBoxDev
@WhiteBoxDev 2 жыл бұрын
@@BootziePootzie 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.
@francescocarbone8466
@francescocarbone8466 Жыл бұрын
Best work.
@Dragon20C
@Dragon20C 3 ай бұрын
I didnt understand why you had "count" in the diamond function, looking at your github in the description made it easier to understand, it was used to make sure its inside the controlled grid
@DobinSergei
@DobinSergei 6 ай бұрын
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.
@jamesmunroe6558
@jamesmunroe6558 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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.
@cazpfitl
@cazpfitl 2 жыл бұрын
pretty cool
@aazimmermann
@aazimmermann 3 жыл бұрын
Any ideas on how we can tile the tile segments generated by the algorithm where each tile is unique?
@Inevitablerizzler
@Inevitablerizzler 3 жыл бұрын
This is what notch used in his ludumdare game Minicraft
@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.
@mattzrsimon
@mattzrsimon 3 жыл бұрын
Very nice video!
@hatac
@hatac Жыл бұрын
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.
@sergodobro2569
@sergodobro2569 Жыл бұрын
Respect to pseudocode!
@wynniebun
@wynniebun 4 ай бұрын
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?
@theb1524
@theb1524 3 жыл бұрын
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.
@GaryMcwr
@GaryMcwr 4 жыл бұрын
Is there a reason why the only subtitles option for the video is Korean?
@turkeyphant
@turkeyphant 4 ай бұрын
3:44 makes no sense. where are these diamonds?!
Lazy Flood Fill | Procedural Generation | Game Development Tutorial
13:32
Fractal Noise | Procedural Generation | Game Development Tutorial
19:35
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Minecraft terrain generation in a nutshell
25:49
Henrik Kniberg
Рет қаралды 165 М.
Better Mountain Generators That Aren't Perlin Noise or Erosion
18:09
Josh's Channel
Рет қаралды 444 М.
Procedural Generation using Constraint Satisfaction
32:36
Programming Chaos
Рет қаралды 18 М.
Cellular Automata | Procedural Generation | Game Development Tutorial
15:22
Generative grammars as a form of procedural content generation
7:50
The Shaggy Dev
Рет қаралды 12 М.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,7 МЛН
Perlin Noise in Python Revisited
6:52
Supreme Sector
Рет қаралды 9 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН
Brian Walker - Procedural level design in Brogue and beyond
32:47
Roguelike Celebration
Рет қаралды 53 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН