Home Technical Talk

Interactive Foliage in UE4

triangle
Offline / Send Message
HarmlessNL triangle
Hey everyone! 

You can’t help but feel that things are missing in your game when comparing your title to gorgeous AAA productions like Uncharted 4: A Thief’s End and Zelda: Breath Of The Wild. But that doesn’t mean that we can’t be inspired by them. One thing that really stood out to us is their extensive foliage interaction. We set out on a journey and delved into the possibilities of making our environments more believable and alive by adding that same layer of interaction. 

I started my endeavors by researching and testing different implementation methods for foliage and its responses to player interactions. In the following post, I’ll share my results and findings with you and shed a light on techniques I’ve used.  So, without further ado, let’s dive straight in! 


Interactable physics on our foliage!

As far as I could find, there are two plausible methods to achieve interactable foliage.  The first method is done through materials and the second method is done through physics.   

Physics
Jonas Mølgaard has an excellent tutorial series that explains how instanced static meshes, such as foliage painted with the foliage-tool, can be replaced by physics versions of that foliage at the exact same location! The principle theory is that you have a Blueprint on your character(s) that replaces all the (instanced static mesh) foliage in an area around the player with a variant that has physics. When the player is out of range, it switches them back to instanced static meshes. Were you to turn this Blueprint into a component, you could easily bind this functionality onto animals or even grenades. 


Here you can see the foliage swap happening! The grey plants are physics objects and the green plants are painted instanced static meshes.

What makes this technique incredibly useful is that at any given time, you will only have a few physics-plants in your game. Considering the relatively low-cost in performance versus its amazing results makes it a very viable option. One of the more significant improvements that I made to Jonas Mølgaard’s system was adding a cap on the amount of physics-actors that were allowed to be active at the same time.  When and if the cap is passed, the system will drastically reduce the number of physics-actors to save performance. 

It wasn’t just smooth sailing, however. We ran into a problem. The materials we used on our instanced static mesh foliage did not support skeletal meshes (your physics assets are skeletal meshes).  We created most of our foliage using SpeedTree and unfortunately discovered that we couldn’t use a SpeedTree node with a skeletal mesh supported material.  This meant that we had to duplicate our materials and remove the SpeedTree nodes altogether. 

Another issue that occurred was from a SpeedTree node that allows for random color variation, which would not work with the ‘magical’ reappearing of physics-actors based on range.  Every time our physics-actors popped back in, the color, that is based on a random value, would be, well... random.  Although the color variation was modest, the colors would be different every time foliage was replaced by the system. Sadly enough, this issue meant that whenever we swapped static meshes with physics-actors, the colors would be different, resulting in a very noticeable pop.  In order to reciprocate this, we created a material function with our own splat-map-based color variation system, without the use of SpeedTree nodes. 

Material
Another method for foliage, which you often see in games, is a material technique in which foliage is bent away from the player.
 

You can see the material technique used in Zelda: Breath Of The Wild in which the plants bend away from Link.

We recreated this effect with much help from the awesome Unreal Engine community; they have a great post about it here. It might not look as sweet as physics-actors, but it’s very cheap when compared to the physics solution, while still maintaining a relatively convincing look. 

I wanted to create a material function based on the Unreal Forum post with adjustable radius's and strengths that would be multiplied by the player’s speed and direction.  This allows for a more convincing effect which, depending on the player’s velocity/speed, would cause the foliage to react appropriately.  When you run into a bush, that bush will rustle more than when you simply walk into it, adding a layer of realism. 


Here are two foliage types from RITE of ILK that use the material technique.

So, what method did we eventually go for?
Well, in the end, we decided to use both methods! We felt that for smaller foliage, such as grass and smaller bushes, the material technique is a great and believable effect that doesn’t require a whole extra level of interaction. Instead, we decided to use physics assets for our unique foliage, bigger bushes, and plants, allowing the player to mess around with it. I feel that this combination is the best of both worlds and considers both performance and visual appeal.  With this, we have been able to add a new level of believability and immersion to RITE of ILK. 

We truly hope that this post can help some people make the best out of their foliage and make it come alive!  If there are any questions, feel free to leave comments and I’ll try my best to answer them.

For more information about RITE of ILK, visit our website! We also have a blog covering a whole range of game development issues and are active on twitter and facebook.

Greetz!

Jori Kamp
Game Designer at Turtleneck Studio
Currently working on RITE of ILK

Replies

Sign In or Register to comment.