Increasing the Limit on Landscape Grass Types

Article written by Ryan B.

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:

	case 5:
		OutColor.x = GetGrassWeight18(MaterialParameters);
			OutColor.y = GetGrassWeight19(MaterialParameters);
			OutColor.y = 0;
			OutColor.z = GetGrassWeight20(MaterialParameters);
			OutColor.z = 0;
			OutColor.w = GetGrassWeight21(MaterialParameters);
			OutColor.w = 0;

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.

1 Like

I know this is older and thank you for this idea, but one question: Is it possible to add more than 21? In older version I read about a limit of 40. Why did they change this?