rdInst Tutorial 6.9 – Baking Foliage Actor Data at Runtime


This tutorial is another example of Baking Proxy data for volumes of instances – in this case, we’ll be baking a forest painted with the FoliageTool.


Step 1. Create a new level with the FirstPerson template.

First step is to create a new level. We’re going to move around as a FirstPerson, so use the FirstPerson Template, or select the FirstPerson GameMode in an existing level.

The level will also need a Landscape, so create a simple default landscape from the Landscape tool.


Step 2. Set up the Proxies on the Meshes you’re using

Now locate and select the Mesh Assets you’re wanting to use in the Content Browser, right-click and select the “rdInst->Proxy Settings” option in the rdInst menu. The Volume Baking only supports ShortDistance Proxies (although any distance can be set for them) for now, so set up a ShortDistance Proxy with the actor/s you’re wanting to swap to when close.

This example just sets both upright trees to the same proxy actor.


Step 3. Paint some of these Meshes with the Foliage Tool

Head over to the “Foliage Paint” tool and drag your meshes into the Foliage List – then start painting some onto your level.


Step 4. Set up the Bake at Runtime

Now all that’s left is to bake these meshes into an rdInst GridArray, which is what the “rdBakeVolumeTransformsForProxiesX” function does. This is a spatial array with fast, localized scanning.

Create a new Blueprint subclassed from Actor, drag one into your level then open it in the Blueprint Editor. In the Begin Play event, add this code. The rdGetSidsInActor node returns the static mesh sids it finds in the volume (works with actors too), that gets passed to the BakeVolume node to add proxies and store the transforms. If you haven’t set up a proxy from the ProxySettings window for any of the meshes the previous node returned, they’re not processed.


Step 5. Set the ProxyScan Interval in rdInstSettings

Finally, make sure to set the ProxyScan Interval in the rdInstSettings to a non-negative value.

Step 6. Done. Play the level

That’s it – now just play the level to see the meshes swap to their proxies when you’re close to them.