- Home /
Stitching grid of terrains together
I'm having a really hard time with a routine I'm writing. I have a 2D grid of x number of 2048x2048 terrains that were randomly generated independently. Therefore, their edge heights and detail/textures don't match. In order to make them seamless, I run through and start adjusting all the horizontal edge heights at about 10% of the way off each edge and I interpolate. Then I do the same for all vertical seams and then I worry about blending the splatmaps. The problem is, the vertical pass screws up the heights from the horizontal pass. I've tried so many things and I just cannot comprehend writing a routine that can stitch my grid correctly. I've seen a tool out there that stitches a bunch of terrains into one but, for me, it's important to keep them separate. They need to fit together but remain modular. And I will not be stitching all of them at once. I'll run the routine here and there to just handle a group of neighboring terrain tiles. Any ideas on such a process, in C#?
Thank you in advance!
Answer by Beks_Omega · Sep 26, 2017 at 05:15 PM
Idk exactly how your terrain generation works but this guy has an interesting series on it: https://www.youtube.com/watch?v=4olmeStiBsE&list=PLFt_AvWsXl0eBW2EiBtl_sxmDtSgZBxB3∈dex=10
That's the episode where he deals with the problem it seems you're having.
And here's all the assets and things from that episode: https://github.com/SebLague/Procedural-Landmass-Generation/tree/master/Proc%20Gen%20E10
Hopefully it'll give you a starting place! And if it doesn't I hope you can figure something out! Sounds like a really cool & fun project!
Thank you so much for your reply. I watched the video and looked at his C# scripts. I still don't get where he meshes his terrain "chunks" together. He talks about having multiple chunks and he illustrates it and also shows a seam where vertices are not aligning. In the code he writes during the video, he seems to be dealing with issues surrounding heights exceeding 1 rather than talking about adjusting edges of terrain chunks so they fit together. I seem to have completely missed where he did that. This might be easier in his case because it is his own procedures that are generating the terrains to begin with. $$anonymous$$y chunks were generated using Gaia so I don't have the liberty of adjusting my terrain generation in order to keep tiling in $$anonymous$$d. Thanks for the kind words about my project :) It is an $$anonymous$$$$anonymous$$ORPG game that I plan to make so vast that the client couldn't possibly have a whole continent in memory at once (or generate it all at once), hence my chunked/tiled approach. I've almost completely nailed down the game engine, including many many spells and monsters so, now, I'm trying to focus on generating the world.
Actually, I figured it out. There was nothing wrong with my code at all! The terrainData for one of my terrain pieces was improperly set and it cost me days of frustration plus I ended up spending $5 on someone's package from the Unity asset store that I didn't need. It takes way longer to stitch the pieces and it doesn't even handle texture blending. Once I fixed that messed up piece of terrain, $$anonymous$$e magically started working, and much better than the $5 purchase from the store.
Oh well, I'm glad I got it though :)
Yay I'm glad you got it figured out! Also sounds like you've got a sweet game planned, and I bet the terrain generation is gonna make it even more awesome! Good luck with your program$$anonymous$$g endeavors!