Get Landscape height in material applied to a static mesh

Ground texture is a demo megascans one.

Not being a CryEngine user, I was initially pointed to this technique, demonstrated in a video, by ZeroNight.

Whatever you call it, in the essence, it is just alpha blended terrain. Not sure how it is done in CryEngine, but in UE4 my workflow was as follows:

  • Run early depth pass for terrain conventionally.
  • For base pass of terrain, ensure that terrain is the last thing to be rendered in base pass from solid and masked objects
  • switch depth test to always
  • configure blend state to use source alpha
  • offset the terrain closer to the camera by amount, equal to maximum soft depth test rage plus small bias
  • calculate final alpha as a typical depth fade, multiplied by manual depth test, biased by a range of soft depth blend.

That is only doable after quite a few modifications to the engine though.

In CE, soft depth test and integrating meshes into terrain are two separate independent things, but latter greatly reinforces the first one.

Integrating meshes into terrain allows you to have minimal soft depth test range, while giving you large blend regions.
Without modifying terrain to closely follow the mesh, You would need to ramp up soft depth blend window so high, that you will start seeing a ton of problems, ranging from misplaced shadows to dreaded blurring in the blend region, caused by the fact, that velocities will be calculated using original terrain depth before offset.
And even at soft test range of just few units, you will already feel drift between surfaces being blended, so this is the effect, not suitable for everyone. I personally dislike it.
It is not free in terms of performance either. You are running depth pre-pass, but not getting any benefit from it and paying full overdraw hit from landscape(This is specific to my implementation at least).

Last but not least, You can’t selectively blend things. The terrain will be eating feet of your characters alive >< .

If you can get your mesh to follow terrain quite close(pulling up vertices of tree roots using heightmaps is exactly the case) soft depth test is good.
In other cases, it is next to useless, and decals, suggested by above, are actually a better alternative, as I see it.