Simone Lombardo broke down an exciting UE4 experiment in which he created the effect of spawning plants by shooting a gun.
Hi, my name is Simone Lombardo, I'm originally from Belgium but have been living in the US for the past 10 years. I have been working in VFX and gaming for almost 15 years now. I was FX TD on multiple movies, commercials, and events; then, I moved into motion capture and finally game engine technology, especially using real-time graphics in TV Shows and VFX, as well as VR with at my previous company, Suspended Reality. I joined Epic Games a bit less than 3 years ago as a Technical Artist at their HQ in Cary, North Carolina.
I spend my free time tinkering within the engine and playing around with interactions, tools, and overall tech art. I love experimenting with technical concepts.
One of the recent professional projects was Mission AR which we created with Microsoft using the Hololens 2. It was such a pleasure for me to work on this project. I learned a lot and have been experimenting with the Hololens 2 since then. I am now part of the Advance Project Team at Epic Games working with the latest technologies in an enterprise context. Before the Mission AR project, we delivered The Speed Of Light with Porsche and Nvidia. It's really fun, and I can't wait to show what we have been up to.
In my personal time, I have been toying around Synesthesia, a UE4 Audio Engine plugin, and can't stop tweaking and playing with it. You can get more info in the recent Inside Unreal episode, State Of Audio in 4.25.
I was watching the PS5 reveal and this gorgeous looking game Kena from Ember Lab was shown. During the trailer, there is this grass reveal effect, and I thought it was awesome. So, as I had UE4 open, as always, I started to play around and try to see if I could reproduce it. And came up with that small video.
From there, I have to admit that I stopped watching the reveal and kept on playing with it. I wanted to get more interaction, more control. I wanted to "shoot" grass.
Structure of the Effect
The structure is quite straightforward. First, the gun fires and line traces to a location. At that location, an event triggers an animated mask that grows and modifies a Render Target, basically "painting" the mask. This mask drives a Material Function in the foliage, which allows them to grow. The foliage is always there, just the size of a vertex. The great thing about that is that it is kept if you stop playing. That is why the vegetation is still there when I press Stop. Because the Render Target has been modified and Unreal Engine keeps that modification. I did include a small Editor Blueprint that "Clears" the Render Target to be able to restart when I wanted.
All assets are from Quixel Megascans. It is so great because they all use the same Material as parent, so I only had to put my material function into the Parent, and then I could load any vegetation — it just worked!
Effect Setup in UE4
All in all, the setup is pretty simple and could definitely be optimized. I’m working on that right now!
The first thing is the Material itself from the vegetation. I built a small Material Function so I could reuse it on different materials. The idea is to leverage the World Position Offset. What the Material Function does is add a small time-based animation that scales the mesh based on its pivot, by animating the vertices.
For artists more interested in that, I would recommend watching the Technical Artist Bootcamp session from Ryan Brucks at GDC, which goes in-depth into World Position Offset and overall Tech Artist tricks.
Once this is done I need to somehow trigger the vegetation, otherwise, if you leave it that way, it will just grow at EventBeginPlay. At first, I used a SphereMask and Material Param Collection that would control it, to make sure all the foliage is affected the same way. This worked great for the original "circle" reveal and let me easily add an emissive edge to the circle to give that extra effect.
But it was annoying to try to get it happen at multiple places. So I thought about another way to control it; I wanted to literally "paint" my mask instead of using a SphereMask.
To do that, I went the Render Target route. Instead of using the SphereMask to control the effect, I used a planar projected Render Target; the Render Target is easily accessible through BP and can be painted at Runtime.
To modify the Render Target, I used another Material as the "Paint" that would basically add to the Render Target during gameplay. That Material is super simple and is just an animated SphereMask multiplied with an overall noise Mask based on the texture for a bit of variation.
From the Pawn Blueprint, when I press "Fire", I then do a small line trace, and it triggers the "Paint Material" at the trace location that animates and adds to the Render Target. The Render Target then controls the mask for the foliage to grow (it is also clamped there), revealing it and triggering its animation.
So it goes Shoot -> Paint Mask -> Mask triggers growth -> Growth affects WPO
Using this technique or the SphereMask, a lot can be done. Like this version where the vegetation follows the steps of the player, for example.
Can It Be Used in Production?
This specific version can definitely be optimized, it also has a drawback as it works only on the foliage that is already in the level (there is a parameter in my Material Function that lets me easily switch between foliage visible/grow mode). On the one hand, it's nice to have this control but on the other, it doesn't allow for much modification of the foliage placement.
The growing + Render Target is relatively cheap (the Render Target is only 128x128). If the foliage fully shown runs smoothly, then the fx will not affect the performance much.
Future Development of the Project
As I mentioned in the comments on my LinkedIn, I am working on improving this effect and add more options. It could be used to literally spawn the instance meshes as needed vs having them already placed in the level and just revealing in certain places. In that case, there is no "preparation", the player will decide where the foliage will be and what kind of foliage he wants (I posted a blueprint graph showing how it would be done).
I also ported it to the Hololens 2 for fun using the spawning method. I am working more on that right now and I hope to post it when I get the time. I also have a small playable demo that I am working on when the time permits. My plan is to release it alongside the project. It shows multiple gameplay cases where this could be used, as well as gives more control to the user over which foliage gets affected and when. But I always get carried away with other tests and work of course, so I have no idea when I will finish that. It should be quite soon.
You can find me here: