Friday, August 1, 2014

[UE3/UE4] Landscape Grass Blending

Authoring grass and landscape textures to blend nicely can be pretty tough at times. This is where automated methods come in handy.

For the following material to work you'll need some kind of a terrain base color texture which is then being sampled in the grass material. The most important part is to make it match the actual landscape size, scale and location.
Once this is done you might find various ways to alter the grass color based on the underlying terrain. In this example I'm using a simple vertical gradient to blend between both textures.



Regular Grass Material

Terrain Blending Grass Material


  1. This is really really cool and thanks for sharing the shader!!!

    the only feedback I have is that because of it you have now to watch your texture better, the blend is nice but still it should have a distinction between the materials it should have a higher range of the value

    here I made it in Black and white to illustrate what I mean

    right now there are almost no difference between grass and terrain value so it become uncomfortable to look at it and if you added a more variate type of grass(a little brighter grass) this would become even a bigger problem but its not a hard fix just need to rework the textures and keep in mind the value range of the textures.

    anyway great work this helps a lot to make things work together :)

  2. Hi, thanks for your comment.
    Like I said there are many ways of blending the terrain texture in the grass material, it's completely up to you. Whith the setup above you could simply tighten the gradient by using a larger exponent for the power node. Or adding a clamp afterwards which limits the max to a value less than 1, so there's always a certain amount of the original grass color being preserved.
    Some people on the other might don't like the gradient transition but want the grass to get an overall color teint from the terrain, that's possible as well.

    Just a different example,
    Tight Blend:

  3. Thanks for sharing this info Oliver, it's extremely helpful.
    This effect works great when using grey scale details maps over the top of a full color terrain texture but I was wondering if you knew how to get this same effect when using full color detail maps over a desaturated terrain texture, which is what I'm doing. Or is it not possible.

    1. Hi,
      I'd suggest to create a base color terrain texture just for the grass blending. This one could be rather small (512²px or 1024²px) but it's way faster than re-creating the whole landscape in the grass material by sampling multiple textures.
      For the beginning you can simply take an (unlit) screenshot in the editor with all actors hidden, except for the landscape. If you want the texture to be more high-res, place an ortographic camera with a top-down view in the level and take that screenshot in-game using the 'HighResShot' console command. Afterwards crop the screenshot in photoshop and re-size it to get power of 2 dimensions.

      For further reference you might want to have a look at this presentation about landscape rendering for The Witcher 3 were they've been doing similar things (p.53):

  4. Aww why didn't I think of that. That's a great idea!
    And thanks for the document link, it's a very interesting read all round.

  5. Can you overpaint on this screen whcich nodes did you used in shader editor? Im starting with UE4, and I want transfer my level from Cryengine to UE4, starting with grass. And I cant get it look even decent.

    Can you do that? It could be more than appreciated.

  6. godlike, i was looking so long for this kind of shader since i saw this once on youtube.
    great work, big thx and greetings.

    keep it up !

  7. Hey there Oliver!
    i've been trying to use your way of displacing the UV's, and have been able to produce the expected result just once!
    i cant figure out where the number 505 comes at the "landscape scale" node. it cant be the section size of the landscape, its not a part of your overal resolution. the only thing i can think of is the total components, but thats not it either.. i've wasted a lot of time so far to figure it out but cant find the answer.
    could you please tell me?

    bunch of thanks in advance

  8. Hi Anton,
    in fact it's the landscape size or landscape resolution. Epic seems to use different names for UE3 and UE4 but they refer to the same.

    If you create a new landscape in UE4 the property is called "Overall Resolution" - that's the value you'll need.

  9. hi :), awesome stuff dude.
    is this type of blending also working on meshes?
    for example: you blend foliage on Landscape, my question is if i have a single mesh ( a rock for example) and want to put a grass texture on the top of this mesh and set some foliage on it. iam totaly new in this and couldnt find any similar guides like yours. greetings and good job so far :) !