Landscape Materials and performance

I am still a beginner with Unreal Engine and recently spent a lot of time with materials and landscape materials. I followed several tutorials and kind think a good a pretty good grasp on creating and using landscape materials. To learn I use Unreal documentation and different Youtube videos. But I still have a few questions for clarification:

I created a landscape material that I want to use for instances to paint my landscape. Here is what I did. I’m using 4 materials with layer blend, Grass, Dirt, Forest ground, and Rock. I made layer blends for Color, layer blends for Normal and a layer blends for Roughness. I made parameters for tiling for each material (with the LandscapeCoords), parameters for roughness, as well as 2D parameters for all textures, so I can change those directly in my material instances. I also used two different methods for reducing texture tiling. First, a made a material function for micro/macro variations using the MacroVariation texture from the starter kit including contrast control, and also a Distance Tiling using CameraDepthFade.

For now its all layers with weight blend. I wanna play around with that and later make the same material with height blend. It works very well, and I basically got rid of most of the texture tiling effect. I am very happy with the result.

Now the questions:

  1. Performance: this material now has 215 instructions (base pass shader). I don’t know if that is a lot or normal. Can someone please give me an idea if this would be considered cheap, normal, or expensive in terms of performance. I’m planning to use this on PC only. The same material was 179 instructions before I added the Distance Tiling using CameraDepthFade. Is the difference of 36 instructions expensive for this kind of tiling effect?

  2. Currently I’m using 4 material layers. How you guys would approach it if you would add a couple of layers more. It would be nice to have another one for Sand, and one for water (puddles). Or is there a different way to make puddles, besides painting puddles in with a water material layer. Would adding one or two material layers cause bad performance issues?

  3. For clarification, is this correct: they way I understand it is that in regards to performance its important that I don’t use too many material layers per landscape component. So, can I for example set up a material with, lets say, 8 different materials, but as long I don’t use more than, lets say, 3 or 4 materials per component it will not affect performance negatively? So I could use in one landscape component the materials with Grass, Ground, Sand, Puddle water, and another landscape component Grass, Gravel, Rock, and Snow. Would the performance be the same as if I use a material with only 4 layers all over the map? I read somewhere that the engine ignores unused material layers per component (correct?). Is it also correct that 3 to 4 material layers is kinda the sweet spot when it comes to variety and performance?

Thanks!

“How long is a piece of string?”

“Performance” depends entirely on the target.
Do you want to run on a five year old Ultrabook with mobile CPU and Intel Integrated GPU?
Do you want to run on a three year old gaming laptop with four cores and a GeForce 1060?
Do you want to run on a recent 32-core Threadripper desktop with a GTX 2080 Super?

I’d say that your terrain is probably OK for the three-year-old computer, and probably heavy for the ultrabook, and probably not a problem at all for the desktop. But your needs may vary.
You need to set up a machine (or a few machines) with the OS / CPU / RAM / Disk / GPU that you target, and measure on that machine. Does it hit the target frame rate? Then you’re good.
There is no other way to know whether your shader is “fast” or “slow” – it has to be in context of something.

You are correct that the landscape material baker will make component shaders that only blend the 2-3-4-5 materials you use for that component.

Yes, 3 materials is the sweet spot, because it fits in most older and mobile graphics hardware, and still gives you enough variation that you can blend each component with its neighbors. Add clutter geometry to add more variation. (Generally, modern low-end hardware is less sensitive to instanced vertex transform cost, than it is to pixel shader fill rate.)

Thank you for the answer. So, when you talking about clutter geometry you means throwing in some static meshes like twigs, pebbles, ferns, rocks, grasses etc?

Also, when you talk instanced vertex transform cost, you mean adding instanced static meshes of different shapes and sizes as the above mentions wigs, pebbles, ferns, rocks, grasses? Correct? And Pixel shader fill rate is for filling/painting the landscape material with the texture files?

just make a bad grass mesh with 10k triangles, place it with the grass material node at a density of 100x10m and check your performance.
if you are below 120fps at 2k res your landscape material can use work.

Note: you HAVE to balance the landscape LOD for any benchmarking to work.
if you just leave it at default you can’t understand what kind of performance you are getting.

To do that, remove the landscape material and make sure that the LOd distribution and base MS cost of a world grid material landscape with proper lighting is below 8ms across the board.
(if you place the camera at the center of a component you’ll see a difference in rendering cost unless you balance your LODs.)

As far as the rest goes, there is another active topic here in which we are covering the best approach and more detailed pointers you may want to have a look at.

Re puddles a different mesh on top of the terrain with a different material that blends into the terrain is the way to go.

And re layers.
the more display the more insteuctions your material uses, the worse performance is…
however you cab get green performance with 20 layers if you do things right, so its not necessarily true that each layer adds a lot. It depends on the layer. The size and quantity of texture samples in use and a bunch of other things…

That sounds right to me, yes!

Hey, do you have a link to this thread, unable to find using search function :slight_smile:

https://forums.unrealengine.com/development-discussion/content-creation/1773932-attempting-displacement-on-landscape