x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.10
Tags:
material graph.txt (46.3 kB)
more ▼

asked Dec 14 '15 at 03:47 PM in Using UE4

avatar image

Sitrec
313 21 23 22

avatar image DamirH Dec 14 '15 at 05:38 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

  • Jack

more ▼

answered Dec 15 '15 at 10:57 AM

avatar image

JackP_oldaccount
1.3k 37 11 48

avatar image DamirH Dec 15 '15 at 01:17 PM

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

avatar image JackP_oldaccount Dec 15 '15 at 02:04 PM

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.

  • Jack

avatar image DamirH Dec 15 '15 at 02:07 PM

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?

avatar image JackP_oldaccount Dec 15 '15 at 02:17 PM

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.

avatar image Sitrec Apr 07 '16 at 03:55 PM

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.

Thanks!

avatar image JackP_oldaccount Apr 08 '16 at 09:41 AM

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

avatar image Sitrec Apr 08 '16 at 04:41 PM

Fantastic, thank you Jack!

avatar image Sitrec Jul 25 '16 at 11:08 PM

Hi again Jack. 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.

avatar image JackP STAFF Jul 27 '16 at 06:03 AM

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

 #if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 10 


and

 #endif // NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 14

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

  • Jack

avatar image Sitrec Jul 27 '16 at 08:30 AM

Great, thanks again Jack!

avatar image aiiven Sep 28 '18 at 04:15 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question