Programming Terrain Generation for my Farming Game
HTML-код
- Опубликовано: 4 окт 2024
- Devlog video about "Homegrown", a casual farming game I'm creating using my own engine. This time I use the dual-grid approach to generate some nicer looking grass and path meshes!
Oskar's talk about the dual-grid (starting at 5:08): • SGC21- Oskar Stålberg...
Support the channel on Patreon and get access to the code for this game, the city-builder, and Equilinox:
/ thinmatrix
My previous game "Equilinox":
store.steampow...
You can follow the progress of the game on my social media:
Twitter: / thinmatrix
Instagram: / thinmatrix
Facebook: / thinmatrix
Trello: trello.com/b/W...
Email: thinmatrix@gmail.com
Background music by Jamal Green:
open.spotify.c...
Outro music by Dannek Studio:
/ dannekstudio
#devlog #Homegrown
It would be nice to see a video about the game performance and the optimization of your development process. This video is amazing as always. Thanks
I second this, though with the upload schedule he has, I assume it's probably too much extra work...
Nice idea, I'll try to do a video about that at some point!
As Donald Knuth has it: "premature optimisation is the root of all evil".
Mind you, I've met coders who misread that and use it as an excuse not to do any optimisation at all, when the keyword there is "premature". Not "don't do it at all", but "only do it when you need to, and towards the end".
More specifically, I'd refine Knuth's advice and say that optimisation needs to be a "top down" process. Start at the highest level - the algorithm - and work your way down from there.
This is just logic. There's no sense, say, spending ages scheduling individual CPU instructions to get a routine super-fast and then going one level up to optimise the algorithm... because it's quite possible that a better algorithm might not even need the routine you spent ages optimising, or at least it'll likely be radically altered.
The underlying logic is that the high level is composed of the low level. Routines are made of instructions, classes are made of routines (and data), classes are put together to make a program, etc.. So there is a natural directionality there.
And part of "premature optimisation is the root of all evil" is a recognition that you shouldn't be messing too much with the lower level before you've optimised the higher levels, as a change of algorithm could invalidate all your previous optimisation work and, you know, that's just a waste of everyone's time.
The other reason to always do optimisation in a "top down" manner - from the highest to lowest levels - is that a high level optimisation (such as changing the algorithm - trivial example: changing from a linear search to a binary search, or changing from a binary search to a hashed search, or something like picking a better sorting algorithm) will net you the biggest wins.
Sometimes a clever re-arrangement can negate the need to do something altogether - and to quote Knuth again, "the fastest code is the code that never runs". For example, you've got some data and you sort it then you search it. But, ah, if you can just insert the data in a sorted order in the first place - always store it in a sorted order from the off - then you don't have to run a sort before you search, as it's always kept sorted all along, then you can drop that requirement to sort before you search. More over, if it's always sorted, then you can run that binary search - O(log 2 n) - to find out where you need to insert new data, so even the on-the-fly sorting of data is sped up over a linear search.
Anyway, yeah, the point in that example is that you need to approach it "top down" because changing the algorithm - from linear search to binary search - will net you the biggest optimisation wins early. Indeed, after doing that, you might find you have no need to optimise any further. That'll do. Good enough.
But if you did this example "bottom up", then you'd be trying to improve the individual instructions of your linear search, choosing a better sorting algorithm. etc. - all of which would be immediately thrown out, when you change algorithm from linear search to binary search. You'd do all that work and then throw out everything you did. A waste of your time.
And this is what I mean about there being a natural directionality to optimisation, and that it should always be applied in a "top down" manner. You'll get the biggest wins first, and avoid wasting your time, when you have to scrap that heavily-optimised routine that took you forever, as the new algorithm you're using doesn't even need it at all.
You get the gist. Indeed, don't even worry about optimisation until you need to - as Knuth advises - because making premature optimisations will potentially just find you "undoing" all your hard work later on.
You spent ages making that sort super-fast, but turns out that sorting as you go and doing a binary search will win you so much more (indeed, I find things like university courses spend a lot of time on sorting algorithms, when usually what you really should be doing is keeping everything pre-sorted - or hashed - in the first place, so there is no "sorting phase" at all).
Start at the highest level and work your way down. If you even need to, as a change of algorithm might just fix your "slow code" problems there and then. But, yeah, bear in mind this natural "directionality" to optimisation. The high level is composed of the low level, so don't sweat the small details until you're damn sure that you've got the overall structure and algorithm - the "big picture" - down pat first. That's where your biggest wins will be - big enough, often, that you need not do anything more beyond that - and it avoids the problem of neurotically re-arranging the small details only to find you don't need that routine at all now, so all that time was wasted.
Or, in short, as Knuth had it: "premature optimisation is the root of all evil".
(And he's as harsh as to say "the root of all evil" just because it's too common a problem for coders to spend forever optimising some low level code, scrapping it, optimising the new low level code, scrapping it... and getting caught in a cycle of doing tons of hard work that, in fact, gets you absolutely nowhere. So he's stressing that you should always just aim to get things up and running first. Even if it's a bit slow and clunky. Worry about optimisation when you need to worry about optimisation. For 2D games or simple 3D like Homegrown, it's very likely that a modern CPU and GPU will easily eat your code for breakfast and never be seriously slowed down, even by the most unoptimal code ever. Getting code to shippable status is often a Herculean task unto itself, so don't add more work on top of that until you really have to. Get the game to work. Then worry about getting the game to work well. Yes, there are, unfortunately, some coders who put off optimisation forever and their code runs like shit - and, to be fair to them, that might just be because deadlines hit and it gets shipped "as is", and they were always intending to improve it later. But, still, do it that way, to avoid getting caught in the "perfectionist loop" where you're working hard forever, yet never ship anything. That's why it's phrased as "the root of all evil" by Knuth, as a bad case of "premature optimisation" can kill a project stone cold dead. Months of work, nothing really to show for it and that first unoptimised version ran just fine anyway.)
@@klaxoncow Thanks ChatGPT, really appreciated
@@klaxoncow Kevin, you're on an Adderall-ramble. Snap back to reality.
The little boost I needed to open Visual and code
I approve of coding.
I disapprove of coding.
Jesus Christ, the dual-grid system was the exact solution I needed for my dungeon generator. You just reduced the amount of object files I needed to cache from 60+ to 4.
I love the look of those paths! The only thing I’m worried about is how the limited space might incentivize the player to replace all their green grass with brown dirt and grey paths. I might have the player constrained in other ways, such as with seeds, fertilizer, etc, to encourage them to decorate. Great work as always, your code is a work of art.
Thanks! And I've got various ideas for why paths might be needed or be beneficial in the garden, so adding pathways won't just be an aesthetic choice for the player :)
@@ThinMatrix I was more worried that if replacing grass with dirt and paths was incentivized the player would be pressured into creating a brutalist rather than natural looking garden. Thanks for considering feedback!
@@bobbelcher6742 Ah I see what you mean. Different path types (including grass) will have different pros and cons associated with them, and if I balance it correctly there should be times where the players will want to use one type and other times when they'll want to use a different type. I definitely agree with you, I don't want to gardens to end up looking to brutalist either!
Would be cool to require an amount of grass next to dirt to generate a passive low level fertilization effect on the plants.
@@ThinMatrix Such as bees only visiting (and improving yield) when they have "natural" grass nearby, maybe?
Can we take a moment to appreciate the transition from camera to screen capture at 10:50? Very well done! Your editing is superb! And the videos in general are awesome as well, of course.
fr fr on god on god no cap no kizzy cuzzoh for real ong ong agreed.
No
@@cheezenuts2357 ye
@@pro.giciel9084 yes
The terrain looks much nicer now, I didn't think it would make such a big difference to bevel it a bit but wow!
I'm not a fan of farming games but I admire this series so much! The creativity that your vids beam with is unbelievable. That game is so beautiful, the effort that you put into your games... It's just, I don't know what to say. Keep up with it, you're making something remarkable.
Thank you so much ^^
I have no interest in farming games, but when farming is in a game I love it xD
Looks amazing! Thanks for sharking Oskar's wonderful talk on dual grids. Very interesting talk.
Lovin the chocolatey paths 😅 Also that mesh wireframe at 7:56 is super satisfying for some reason, nice job!
really nice devlog, I understand the tiling system, it makes it so much easier to calculate and render!
Yay !
Really liking the progress so far
you explained the grid system very well and the diagrams were great.
In my opinion, the mix of sharp and round edges makes the game more diversified. Keep it!
I really love to see the while process of developing a game. I've always been a fan of game developing and it's really fun to watch how it all works, a type of content that it's usually hard to find, especially from indie devs, at least during the development phase.
than you so much for taking the time to make these videos.
Superb as always. Some of us really expecting a video about that smooth camera system. 😊
Game designers are geniuses, I'm glad I'm able to copy them
Keep creating! It's wonderful. Good luck
This dude is a genius I love how he planning and executing without any problems, years of experience pays off, keep it up!
Oh believe me, he’s making and fixing all sorts of bugs that he doesn’t show 😂 that’s the life of a developer
@@sky01james28 Yeah totally but as you getting experienced you less and less using google especially when you building stuff like that which you need a good math to handle
Looking great! Love that double grid system. Need to watch that talk, thanks for sharing it!
I LOVE your plant-filled workspace, as a plant fanatic myself
Man it's awesome how much that changed the terrain look. It fits in so much better. Great work
This wholesome coding content motivates me to make and play more games!
great video, the problem around smooth edges, the elegant solution and the explanation were so interesting!
HOLY CRAP THAT LOOKS AWESOME NOW
The amount that increases the feel of the game is insane
The game looks amazing. I can’t believe you made this all using your own engine
Always a good day when we get a new Homegrown dev log! I hope you have been doing well IRL. Looking forward to the next one. 👍🏼
What an elegant solution! One suggestion is that the path tiles should always have bricks on their edges, even when connecting with grass, it might look more connnected that way.
Your code looks so clean. Small files, great use of constants, methods are max 10-20 lines each. The product's looks match the code's!
When I saw your post, I've checked Oscars conf talk but had no clue what it means actually, after seeing your video it's all clear now! :)
I feel like the stones on the dirt path should be gray! Amazing video btw, thanks for sharing your process with us
Interesting! That double grid system is very efficient.
I shall look forward to the gameplay testing and economic balancing phase.
Looks great. The path brings me to the idea, that there could grow wheeds between the tiles over time. Maybe they can be harvested and contain some rare seeds or stuff
This looks way better every update, keep it coming !!
Great progress, great video - as I've come to expect from you. Really love how you show all steps: Idea, proposed algorithm, implementation, result (and resulting complications and their results.) It is not only fun, but it is really teaching how to do things. Not just teaching solutions. Looking forward to you next video.
I absolutely love the minimalist graphics! Well done!
Terrain looks awesome!! I might have to check out that tiling method, it sounds nice
This entire series (or just this entire youtube channel in general, since I have also seen the town game development videos) is absolutely amazing! it has felt so incredibly relaxing and inspiring seeing both stuff regarding what you are developing, but also your lifestyle!
By seeing all the things you do in your life other than game development I feel like it has truly motivated me to do more myself!
Very nice work on this, found it super interesting and insightful, I also think you explained the dual-grid system very well, I was a bit worried I wouldn't get it, but your diagrams really helped to explain it!
And your new terrain looks fantastic! Really adds a lot to the aesthetic!
Dumb idea, but it could be nice to have a thing that if you tap terrain it generates a little sound connected to the terrain type, i.e. clicking the stone path leads to a little stone noise, etc.
It is looking so awesome. I had a smile when you added the dirt terrain type. As a developer myself, I know it is so much fun to add elements even though they might not be priority at the moment.
So many clever ideas in this one! The two-grid system is one of those things where as soon as you explained it I wondered why I hadn't thought of it myself. It's always a pleasure to watch your videos :)
damn how much better the game looks now :) good job!
Man, you inpire me so much, your video videos always show a solid progress, code explanation and great editing, it is just too good! I love it!
I always love seeing the updates you make to your game! This game has so much potential, keep it up!
That terrain double grid stuff is a great idea.
I follow your videos for quite some time and each time I am amazed by how you film and edit your videos, about the dedication of working with your won tech stack, but most of all I like you setup the real world part of you office. I like the plants, the view. From here is looks like a place that's inspiring and where you can go and find idea. My own workplace is quite boring. I have come cacti, but they don't seem enough to give that sensation of a mini garden. Your work is awesome! Keep up the good work
As you were planning it out at the start, I was thinking to myself "what is the name of that guy who has a better way of doing it" and then you're came right to it :) I think the contrast between the sharp corners of the path and the smooth corners of the grass adds visual interest to the game.
Its great to see this project coming together, thanks as always for the interesting and well edited dev logs :)
Love it! Would be cool if the grass tiles generated some small grass on top to make them a bit more interesting, but still, everything looks so cute!
Very nice! I love the idea on how to do your tiles, that's a simple, elegant solution. Nice looking game, family friendly too which I like. God bless.
Thank you :)
A long video, yes! You are so unique with your devlogs, I like how you display some of your life (except this week). Your cooking is great. I love these devlogs.
I really like your office. Your plants really make a difference.
This looks really good, the art is really starting to come along! Excited to see where you go with it next.
Love your work!
Really nice system you got going! I think you did an excellent job implementing it and the results speak for themselves. Your games style is coming together very nicely!
Thank you!
This was such a great update. The thing I love about your devlogs is that you're not so focused on the minutiae of the engine - you're explaining your thought process and methodology but not getting bogged down in specifics. I don't know if that's a product of you using your own engine, and so it's not as useful to refer to specific processes as if you were using Unity or Godot or something, but it's pretty refreshing. There's a high level of thinking on display here and I feel like I could refer back to how you conceptualize these solutions to apply them to my own projects, irrespective of what engine I'm using. Not sure if that's a conscious choice, but it's a major strength of your videos.
Great to see you back with an update. Always brightens my day to see a new episode 🙂
So clever with the new terrain system! 1:26
And it looks beautiful, too! Well done!
Amazing, just amazing. You have excellent coding and video editing skills. Keep up the great work! Glad I came across your channel!
The terrain looks great and was super interesting to hear about the dual grid system!
I know this terrain system as the main/sub grid system. it has a lot of advantages for height maps, shadow baking and LOD (level of detail) and for procedural terrain generation when your terrain gets so large that you only render parts of it.
Genuinely my favourite gamedev creator - Always looking forward to your videos!
The progress is always, You should make some day in the life videos even if it isn't to do with programming, Been watching for years and love all ur content man! I still get excited for every upload you do!
Your game reminds me of Viva Pinata, that title is really close to my heart and always reminds me of such good memories. I feel like you were able to convey the same warm feeling with your style! Love your channel, keep up the good work!
I know that my words won't do much but feelings...
Thank you!
Really interesting video.. Thank you for your insights and explaining everything so well. :)
The new terrain gen is looking really good! I think it would be cool if the dirt path borders were made up of wooden logs or beams. Maybe even the short upright stumps that you see as borders in some gardens. Possible would make more sense than bricks made out of dirt?
Thanks :) And yeah, that could be nice! I would like to add support for other possible border types, but I'll have to save that for the next time I work on the terrain.
Love the more technical styled video! Great work :)
I love how you show the world, that Java game development is possible, and why Java is one of the best languages out there!! :)
The art style looks really good ✨
Thanks!
I love it when you upload. It always gives me some extra motivation to open up Unity and Visual Studio and work on something of my own.
Man this has really gotten pretty on the last few updates. Can't wait to play it!
Looking fantastic, thanks.
Great devlog! I learned many useful stuff :]
programming and game engine stuff,
Awesome vid! Can't wait to play
Очень классно выглядит, жаль, что видео такое короткое - хочется смотреть и смотреть на работу профессионала. Очень круто получается
Im here for the food prep and I missed it on this video :(
Nice video again
Wow, just those rounded grass borders made a huge improvement!
I think the path pimples are simply a wonderful idea!
Thx for the vlog! Can`t wait for the next one.
I love the rounded grass edges! Honestly, I don’t think the paths even need to be rounded. Also, Oskar is the best.
Excellent update!
Awesome progress! Love the videos, the style is so calming and fun to watch whilst destracting me from doing some dev myself haha
great seeing you again 😊
How cool is this! Very well implemented 👏
The weighted normal trick also works wonders on all kinds of low poly assets. Adding a bevel in blender, shading smooth, and either using the weighted normal modifier or in Object Data Properties / Normals / Autosmooth.
Great to see that you are building yet another awesome game! Keep it up.
For the dirt path I'd make the little rocks grey, so they look less like pimples, and perhaps make the border brown for "wood" since that seems more realistic than.. idk pale clay bricks or something. Already looks great
Man, if I could like twice I would! Love your videos :)
Looks amazing!
Indenting the the stones on the dirt paths to instead have dips in the path might look more natural since the paths themselves are indented.
It looks so good!
this looks amazing! good work looking forward for this game
the nice thing about the brick borders is that they don't have to be brick, giving it a wood texture would work just as fine as a wood/log border, it would also be more logical than the current sandstone border
i love this series
Cant wait for release!
I know you probably know this, but you are a real inspiration to the solo indies everywhere. Good job as always.
Nice. Thinking about pathways made me realize that there surely is going to be a playable character in the game. Can't wait for that :)
This one was great mate ❤