Mar 31, 2021.Knowledge
The current limit of grass outputs per material is 18. If you find that you need to increase this limit then you will need to modify the shader file, LandscapeGrassWeight.usf, where the limitation is hardcoded as it’s not possible through the editor.
LandscapeGrassWeight renders multiple grass layers in multiple passes in which each pass can do 4 layers (the only exception being the first pass). By following this existing logic inside the shader file, the number of supported grass layers can be easily expanded. For example, adding the following code after the 5th pass will expand the limit from 18 to 22:
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 18
OutColor.x = GetGrassWeight18(MaterialParameters);
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 19
OutColor.y = GetGrassWeight19(MaterialParameters);
OutColor.y = 0;
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 20
OutColor.z = GetGrassWeight20(MaterialParameters);
OutColor.z = 0;
#if NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 21
OutColor.w = GetGrassWeight21(MaterialParameters);
OutColor.w = 0;
#endif // NUM_MATERIAL_OUTPUTS_GETGRASSWEIGHT > 18
It should be noted that this shader is only used in the editor to generate the grass weightmaps and that these weightmaps will only be generated for the landscape components that make use of the particular grass types. All landscape components in a single landscape actor should either use the same material or use materials with the same ordered list of grass outputs.