Auto-Material for procedurally generated terrain

Hi everyone,

This is my first time posting here so I am not sure whether this is the correct place to ask the following.

With the help of many tutorials, I were able to set up a system to procedurally generate chunks of terrain that are being spawned or removed based on their proximity to the player character. The height of the terrain is being randomly determined by multiple noise maps.

(Vertices Quantity = 10; Size = 115)

Now I want to apply different materials based on the terrain’s height and slope. However, since the terrain is not a landscape as such, I believe that I cannot use a landscape auto-material. Instead, I tried using VertexNormalWS since each chunk consists of multiple vertices.

This approach does generally work quite well within each chunk. However, between the chunks, seams become visible.

I read somewhere else (https://www.reddit.com/r/gamedev/comments/z1jhh1/lighting_seams_between_chunks_in_my_terrain/) that the problem might be that the edge vertices of the chunks do not have their neighboring chunks vertex normals to include in the normal re-computation.

A possible solution might, thus, be to generate bigger chunks that overlap each other before using “Calculate Tangets for Mesh” and then removing the overlapping part but there might also be other solutions.

However, I have no idea how to do this with Blueprints and could not find any tutorial etc. yet. Therefore, I kindly wanted to ask you all for help. Any ideas?

Kind regards. :slight_smile:

Use a world positioned texture to define the terrain coloring.
The same way the landscape works internally.

If you need it procedural you can use a render target that snaps a shot of the completed landscape mesh with color values for the range of slops you want.
If you put colors in R/G/B/A based on the slope values, you can then use single channels to apply materials. Same as you are probably using vertex paint, but driven off a texture.

Be mindful thst there is a 16 texture limit usually.
So layer materials should be kept simple: 1 diffuse, 1 normal, 1 packed texture.
You can do approximately all 4 layers (rgba) and still use a couple of macro textures to hide seams and repetition.

Many Thanks for the swift reply! :slight_smile:

Sorry but materials are quite new to me. Would you mind to elaborate a little bit further on how to do that?

However, please also note that new chunks are being generated every time the player moves while the old ones are being deleted behind the player. Thus, the terrain/landscape will never be “complete”. So a render target might not work as intended, I guess.

Thanks in advance! :slight_smile:

You can update the render target whenever the chunks update.
Writing ONLY the landscape to it wouldn’t take much in terms of computation. Changing the colors just for it may. You’d have to find a work-around there.

At a base level, you place the texture’s channel as the input to a lerp. the A / B of the lerp are the colors/materials to be used.
To get the UV to be accurate you have to place the texture with a World Position UV node.
How you do this depends on what the size of the screen capture covers VS the position of the actor.
Actor Location in world space will drive the center of the texture. World Position - actor position should be a good start of the UV position. but you also have to account for 1/2 of the size of the texture in use. plus the conversion to whatever it captures.

Best place to get familiar with materials is likely - aside from trial and error - https://www.youtube.com/channel/UCoG9TB1eL6dm9eNbLFueHBQ