How can I create an array of heightmaps and randomize their rotation and position in the world to create a randomized landscape?

Hello,

I am trying to figure out how I can make a pseudo randomized world. The way I was planning to do this is to create a bunch of heightmaps manually, and then generate a world from them.

e.g randomly select 9 heightmaps, and place them in a 3x3 grid in the world with each randomly rotated.

Any help would be greatly appreciated, I am very new to blueprints.

Thanks in advance.

I got somewhat invested into trying something similar but didn’t run with it and am by no means well versed in UE so here goes

You need the world size of the landscape/mesh as reference, one array and two other variables (StartingLand SpawnLocation & CurrentLandSpawnLocation) for starters - Inside a blueprint grab all your land references, promoting as needed if needed depending on where or what BP you use. Feed them all into a make array, or make an array and put them in manually- but then you cant simply get all of class later on if this flies.

Set the spawning rules up, imagine we start from the top left for western reading/logic so starting from 000 in our world space is topleft from a top-down perspective (Dont need Starting Land Loc if 000 is always start point of gen).

For each loop of your array item: A sequence with 2 pins, first pin leads to a do once, second pin blocked by a closed gate or branch.

Do Once loop: Get(Starting LOC) spawn or move your land there, ADD total Y size of mesh to SET(CURRENT LOC) then open the second pin’s gate or branch.

For each loop (sequence pin 2):Get(Current LOC) spawn or move your land there, ADD total Y size of mesh to SET(CURRENT LOC) then check the current array INDEX against an equals node check it against 2 = 2 (Index 2) its a node inside your array to be dragged off. Have a branch, on false nothing, on true however. Add 3 to the next index equals check then; Get the starting location and subtract the lands x axis then set this as SET current spawn location (I think that is that) - loop should keep going in rows of 3, control column size by adding a check for index =8 someplace and close the starting gate again. (Index starts at 0 so an index of 8 will be the 9th item in the array).

Rotation can be done during this sequence, I just never looked into it, make the order items go in the array at construction random. Peace dude, hope you find an answer from either that mess^ or someone more qualified.

This was very helpful, thanks for your time.

Could you please give me some more insight into how I would create landscapes from heightmaps inside the blueprint? At the moment I am creating the heightmaps in L3DT and exporting them as .png.

I understand how to create a landscape from a single png from the editor but I am not sure how I would create an array of landscapes from a collection of .png files inside a blueprint.

Thanks

I am struggling to understand. I apologize if this is something very basic but I can’t find the answers im looking for through google. I am not set on any part of this process.

" I would generate the landscapes and have them stored myself "

I do not understand what you mean here.

As far as I can tell, with the editor I can only manually generate one landscape from one png file. Am i missing something obvious that would allow me to make multiple landscapes from the editor and then manipulate them inside a blueprint?

In my head the process was going to go something like:
have an array of png textures, randomly select 9 of them and create landscapes out of each, and place them in a 3x3 grid in the world as tiles.

I cant see how I would create a landscape from within a blueprint at all.

It seems like you are suggesting I would need to somehow create a library of landscapes manually and forget the heightmaps entirely from the blueprint’s perspective which I am totally open to but I just dont understand how I would do that.

Sorry again if I am missing something basic.

Thanks

Eeeek, I would generate the landscapes and have them stored myself its only a 3x3 permutation. But you want to have essentially a micro 3x3 proper world gen?. Mate I cant really convey that to you myself since the path I will likely send you down may not be the best but there are a few ways; really tho you need to look up modularity and work out what channels and options you have with your .png’s -

You can, for instance; take every heightmap as a texture in a function inside a layered landscape blend and have the world position offset read from it - obv you would need multiple of these because of the sample limit - eventually you will get repetition otherwise, but again 3x3… however I cant explain this to you eloquently or easily :frowning: My own landscape layer BP’s are melting my brain already.

Sorry I hope Im atleast pointing you to the right things; PNG’s colours/modularity - world position offset - as for the mental groundwork on feeding your png’s into the lands for gen - you literally just do the same thing as I said for the landscape gen - only rather than using coords and spawning land, work with the landscape references and an array of your png’s… The landscape could for instance already have a material applied that the offsets read from the png effecting the offset Z

Not at all your fault mate, my personal command of the relevant ‘tech’ lingo is poor, sorry :(.

Yea, I mean generate each landscape manually from your height-maps one by one and then save them as landscapes, reference them inside the BP, make an array out of their references instead. If you cant reference them between “levels” or w/e system you are going for you can always drag the landscapes in manually, run the permutation, then delete the originals you are referencing after the build has no more need of reading the arrays.

This is going to take a lot of mem if my understanding is correct however, so I cant say it is a decent solution, but supposing this is happening during construction or worst case at begin play - once they are loaded (and the dupes killed at start or deleted at construction) you can deal with the 9 terrains LOD - although I cant help or suggest anything for that - I have only worked on discreet maps in the past so this is totally new to me.

As for what I said about doing it from the material using OFFSETS*, It does work I use it - but its not the standard as I understand it so maybe best avoided. - It allows you to change the height of a flat (geom) landscape based on a colour channel inside one of the layers for instance, you can apply a scalar to it in the material and intensify or desaturate the effect of the offset* - use the other channels in your… lets call it “gen mat layer” -(which must be world aligned!) to control other such *offset effects, have the colours masked but the offsets unmasked, paint the map as usual. Oh and the texture size for your GenMatLayer should be fairly large so you can get the most out of modulating the 3 channels details together - creating w/e random undulations where the 3 colours of sinusoidal waves (hint hint) intersect for blending different heights(offsets) together. Ie Channels In Valleys, Red over Green. Change a few nav gen/mesh setting changes may be needed to get it to work, but it works.

You have been really helpful.

How can I create a reference in a BP of a landscape that I have made in the editor?

I now have Landscape1 and Landscape2 in the world outline.

I dont understand how to point a Landscape variable at them in order to manipulate them from inside a blueprint.

This is where i get lost : “then save them as landscapes, reference them inside the BP,”

Thanks again for your time

edit: I have finally figured out the correct google terms to land this page:

By selecting the landscape in the editor and then inside the Level BP I could “create a reference to” the landscape I had selected. It felt kind of clunky and i feel like theres an easier way to do that but progress is progress.

Okay, you can save them by saving the level(map they are on - terminology) and reference them across different levels from within a blueprint; But you will need to look the referencing across different level instances up yourself. However I can tell you how to reference the map pieces you copy in to the level manually you wish to randomize.

Referencing an existing actor is done as a variable inside the BP, add the variable “landscape reference” (light bluish I think), compile; point this reference’s default value at one of your landscapes. Voila you can put them into your BP’s and work on them.

Edit: Yea, and it uses a lot of your mem, but like I said actors can be referenced across “levels” - avoiding this. I think however if your landscapes really are quite large it might be better to follow a terrain generation tutorial to find the “seamless” way this done these days, but I dont know if it allows you to insert your hand generated/made landscape into the mix. - I just happened to have been working on a similar idea as you :).