Unreal 4.8 Grass System

I’ve been trying out the grass system in Unreal 4.8. (To avoid any confusion, I mean the system where the grass density is driven by one of the landscape layers.) It looks very good, a lot like the microfoliage in the Far Cry games, but I’ve got a few questions:

  • The grass seems to be lit properly, but it isn’t affected by shadows. Obviously it would be crazy to produce shadow maps for all the grass instances, but it would be nice if they could pick up shadows from the surface where the grass has spawned. For example, if a grass mesh is spawned on a landscape, and that part of the landscape is in shadow, the whole of that particular grass mesh could be rendered as in shadow. I imagine this could give reasonable results without being too costly, but is it possible with the current implementation?

  • I had a problem where the grass would cut through other objects. For example, if the grass is quite long and a dead enemy is lying on the ground, the grass appears to be growing through the enemy. Is there any way to have the enemy draw on top of the grass, as though the grass were getting squashed?

  • I was wondering about the efficiency of the grass system. Is the idea that the meshes can be spawned by a shader, without the need for the CPU to place each grass mesh individually? In that case presumably the cost is similar to using tessellated materials. Would it be reasonable to have a large landscape which is mostly covered in grass (bearing in mind that the meshes will only be rendered when close to the player) or should the grass be kept for small patches?

Thanks for any help you can give!

Hello PeteX,

The Procedural Foliage Spawner is a new feature and is considered ‘Experimental’ in its current state. With that said, there are known things that need to be addressed and fixed which we are working to have implemented. In order to verify any issues you might be currently experiencing, be sure you have taken a look at the documentation covering the nuances of the feature and how to set it up correctly.

Procedural Foliage Quick Start Guide

This guide contains a lot of very helpful information that help you find answers to your questions. It will also guide you through the set up process and explain the values you might want to change to create a more dynamic procedurally generated area of foliage.

Let me know if you still have questions or comments after taking a read over the documentation.

Thank you,

Hi Andrew,

Thanks for the link! I think I managed to overlook a lot of that documentation, so it was helpful to read through. (I also hadn’t realised I could have procedural forests. I’m looking forward to trying those out too!)

The documentation answers my last question I think. Lots of the examples have large areas of grass so clearly the performance is adequate in that situation.

I’m still curious about the first two questions. My grass was set up (as far as I can tell) the way the documentation described, but shadows aren’t showing up. The second question is higher level. The grass system is doing what it’s supposed to, but it looks odd if it grows through objects that are lying on the ground. I was wondering if there is any way of preventing that.

Thanks again,
Pete

Hey PeteX,

Be sure the grass mesh you are using has ‘Cast Shadow’ enabled as well as adding a ‘Skylight’ as your ambient fill lighting. Also make sure the lightmap resolutions you are using with your procedural foliage are correct. If you would like a different lighting approach take a look at ‘Distance Fields’ and how they are used to greatly increase rendering performance when combined with the ‘Two Sided Foliage’ and other lighting techniques for large outdoor areas heavily populated with foliage. How I have my scene set up is totally dynamic and performs as well, if not better, than if I were to use baked static lighting.

First go into your ‘Project Settings’ and enable the ‘Generate Mesh Distance Fields’ within the ‘Rendering Section’. Save, close, and re-open your project to have the setting applied. Now select the ‘Directional Light’ within your scene and set it to the values shown below.

Directional Light

The ‘Distance Field Shadows’ is a lighting technique which helps provide a cleaner and softer shadows at the set distance. Enable this option and read up on the documentation to understand a bit more about how to use this feature.

Ray Traced Distance Field Soft Shadows

Skylight

Here we are using a ‘Stationary’ skylight which is also casting dynamic shadows. You can turn this off to increase performance, but you will lose a tiny bit of added realism.

World Settings

This makes your scene only build the dynamic lighting and really helps with iteration times when designing large outdoors scenes.

Distance Field Lighting for Grass Type

Here are the settings I am using for my grass type for the Procedural Foliage Spawner.

Shadows Cast and Received

This is what the grass in my small scene looks like with the Procedural Foliage tool and the settings I have mentioned. This should answer your question as to how to get your shadows to function with the procedural foliage spawner.

Your second question deals with being able to detect collision between your grass mesh and your player character, and modifying the material to squash or move when colliding with one another. This is a more advanced approach, but there is content on the market place that has this functionality already in place. It is called ‘Realistic Grass 1’ and might take some tweaking to get the effect you are looking for, but it is a start.

Let me know if there is anything else you need help with, or if you have additional questions.

Regards,

Wow, thank you for such a comprehensive answer!

You are welcome. Just for future reference, when on the AnswerHub and you receive and/or see an answer that you thought was helpful you can up-vote it.

This allows other users to find good answers to their questions if they are experiencing a similar issue as it can filter the highest voted answers as the first priority.

Press that little up arrow next to the start of the answer :wink:

Cheers,