Can't use more than 9 grass types

As requested, here is a bug report for not being able to use more than 9 grass types in 4.10.

I have tried in both my own landscape material i use in our project and a super simple one and both fail to show more than 9 grass types. When I add 10 or more grass types the first one disappears and the 10+ types doesn’t show up either.

The material I made just contains 11 layers named 1-11 and 11 grasses with the same names and random grass types assigned, landscape layer samplers named 1-11 are assigned to the grass inputs…

Here is a copy to paste in an empty material to replicate the problem:

Just assign some grass types.

  • Copy and Paste into Material Graph: link text

I can echo the same issue but with fewer grass types, although the ones I have go from 1 to 6 variations.

Hi, this is a hardcoded limitation in the shader file Engine\Shaders\LandscapeGrassWeight.usf. It renders multiple layers in multiple passes, and each pass can do 4 layer except the first in which the first two values are used for the heightmap.

The original shader file only allowed for 3 passes, which gave 2 layers in the first pass and 4 in the subsequent two passes for a total of 10 layers.

The attached file supports two more passes, so this expands the number of supported grass layers to 18. Just replace the shader with the updated version. You can keep modifying the file yourself if you want more than that.

The attached shader is valid for 4.9 and 4.10.

Hey JackP - does this have any impact on performance if e.g. 18 layers are enabled, but say 12 are used?

That shader is used only in the editor to generate the grass weight data.

The runtime performance really only depends on the amount of foliage you have actually painted in any one area. So as long as you’re not using 18 layers in one place, it’s fine.

Thanks for the info. One last question that came to mind in the meantime - how does performance of these landscape foliage layers compare to actually painted foliage? Was the 10 layer limit an arbitrary decision or are there potential issues (other than performance) when modifying the shader?

Both landscape grass and painted foliage use exactly the same code to render (HierarchicalInstancedStaticMeshComponent). The only difference is that the landscape grass components only exist around the camera and the instances get placed at runtime (in a background thread).

The more grass layers you use, the more memory you will use to store the layer weight maps which are used for runtime placement. For each landscape component it will store 1 byte per vertex for the weight info for each layer used on that component. It also uses 2 bytes per vertex on components with any grass at all, for height placement info. This data is much smaller than the data needed to store info about a foliage instance (around 80 bytes per instance).

The 10 grass layer limit at editor generation time is completely arbitrary and will have a very minor effect on editor performance when it’s actually building grassmaps, ie when you see the notification “Building Grass Maps…” in the bottom right corner of the screen.

I thought I had replied earlier. Thanks for this! I’ve used it since 4.10 but noticed it doesn’t work with 4.11. What would I have to change to make this file work with the new version? I get an error saying the engine can’t compile the default grid material upon starting with this file.


You need a new LandscapeGrassWeight.usf shader for version 4.11 as there have been other shader changes.

I’ve attached a modified version that goes up to 18 layers. You should be able to extend that as necessary.

link text

Fantastic, thank you !

Hi again . I tried modifying the file for 4.12 but I just can’t figure out what changed? The 4.11 file is no longer compatible. Sorry to bother about this all the time.

Here is a version for 4.12. It is currently compatible with 4.13 also and will remain so unless we change anything.

If you diff this with the original 4.12 file, you can see that all that’s changed is the stuff between




Just copy/pasting of that part of the shader before the default: line should allow you to modify any version.

Great, thanks again !

Thank you so much. Your answer is useful even in 2018! It would have been useful to have this limitation information into the documentation. I was getting crazy not understanding what I did wrong and why the 11th grass type was not working. Thanks again!! <3