Runtime Virtual Texturing Quick Start

This guide walks you thorugh setting up a Landscape and its material to use Runtime Virtual Texturing.

Windows
MacOS
Linux

This guide requires proper setup and usage of painted landscape materials to proceed. It also uses materials found in the Content Examples project available from the Epic Games Launcher under the Learn tab. While the materials are not required to proceed, setting up the landscape to function properly with one is. See the Landscape Quick Start Guide before proceeding or open the Content Examples project Landscapes map for use with this guide.

In this Runtime Virtual Texturing (RVT) quick start, we'll walk through the process of setting up and using RVT for your Landscape and non-Landscape components in your own projects.

Before starting this guide, it's important to understand that Runtime Virtual Textures work best with Landscape terrains for a few reasons:

  • Complex Landscape materials cache the shading results for a performance win

  • Improved quality and variation is achievable with spline and decal-type effects

  • Blending of non-Landscape Actors with your Landscape is handled by the same RVT Asset

After going through this guide, you'll have a better understanding of:

  • Setting up a Runtime Virtual Texture Asset and how it connects to different components

  • Enabling Runtime Virtual Texturing for a Landscape Material

  • Setting up a Runtime Virtual Texture Volume in your Level

  • Setting up additional Actors to render to the Runtime Virtual Texture

1 - Project Setup

Before you can use Runtime Virtual Textures, you must first enable it for your project. Follow these steps:

  1. From the main menu, select the Edit menu and select Project Settings. Under the Engine > Rendering > Virtual Textures category, set Enable virtual texture support to true.

    1_1_ProjectSettings.png

  2. Restart the Project.

2 - Creating a Runtime Virtual Texture Asset

The Runtime Virtual Texture Asset contains the configuration details for the RVT Asset assigned to a Runtime Virtual Texture Volume. The RVT Asset also works by linking Materials and other Actors in your scene that need to share data.

  1. In the Content Browser, use the right-click context menu or the Add New button to create a Runtime Virtual Texture Asset from the Materials & Textures category.

    2_1_CB_AddNew_RVTAsset.png

  2. Give the Runtime Virtual Texture Asset a name. For this guide, ours is named VT_Test.

  3. Double-click the Asset to open the Runtime Virtual Texture Asset to configure its available properties.

    2_1_RVT_Asset_Window.png

    From this window, you can define the runtime virtual texture's size, tile size, type of Material Attributes it supports, and enable/disable virtual texturing for debugging purposes. These settings can be adjusted in real-time while working in the Editor to see their changes take effect.

    For details and usage of these settings, see Virtual Texture Settings page.

3 - Creating a Runtime Virtual Texture Material

From this step forward, assets from the Content Examples project is used. It is not required to proceed but is recommended.

In this step, we'll be using a simple Landscape material to have runtime virtual texturing support. In addition to that, we'll set up logic using some RVT specific Material Expressions that allow for the material to fallback to its original use when virtual texturing isn't available on a supported platform.

Setting up your material to work with RVT requires that two contexts be considered:

  • Part of the material will write to the RVT Asset.

  • Part of the material will sample from the RVT asset and apply further logic.

In this example landscape material, taken from the Content Examples project, it has a simple layer blend setup for Snow, Grass, and Rock.

Click image for full size.

If you're not using the material from Content Examples, you can recreate it as shown above. However, keep in mind that you'll still need to properly set up the Material for use with a Landscape. Follow the Landscape Quick Start Guide if you need a starting point.

The sections that follow will break down parts of this Material to demonstrate how we're writing to and sampling from the RVT Asset.

Required Material Setup

Setting up a Landscape material for use with an RVT Asset is the same as setting up a traditional one, with one exception; Use Material Attributes should be enabled. This option enables use to use Make Material Attributes expressions to rebuild and output the material for different use cases supported.

  1. Open your already created or available Landscape material. Right-click in the graph and search for a Make Material Attributes expression. Add one to your graph.

  2. Move the wire connections from the Main Attributes node to the Make Material Attributes node. You should have something that looks like this:

    Click image for full size.

  3. Now, with the Main Attributes node selected, use the Details panel to enable Use Material Attributes.

    3_1_3_EnableUseMatAttributes.png

  4. Pull off the output of the Make Material Attributes node and create a Runtime Virtual Textures Feature Switch node. This should plug it into the No input. Then, connect that to the Material Attributes output.

    3_1_4_RVTFeatureSwitchNode.png

Your material should now look like this:

Click image for full size.

Writing to the Runtime Virtual Texture Asset

Next, the material needs to write to the RVT Asset through the Runtime Virtual Texture Output expression. This node, references the RVT Asset created earlier in this guide and enables corresponding Material Attributes (such as Base Color, Roughness, and Normal) to be used as input attributes of this node.

  1. Right-click and add a Runtime Virtual Texture Output node to the graph.

    Click image for full size.

  2. Connect the node wires for each material attribute input that is listed on the node. For ones not used in your base material, use a constant value in its place.

    3_2_2_ConnectRVTOutputInputs.png

    TO limit confusion of wires in complex material graphs, double-click on any wire to create a reroute node. For example, adding one on the wire for inputs like Base Color or Normal can be useful to have a single wire handle both inputs for the RVT Output and Make Material Attributes nodes.

Your material should now look like this:

Click image for full size.

The first part of this material is where all the layer blending and logic is happening. It is all the camera independent shading that can be cached to the RVT Asset and other objects (such as splines and decals) are expected to be composited to the output of this node by the RVT System.

Sampling from the Runtime Virtual Texture Asset

Next, the material needs to sample from the RVT Asset using the Runtime Virtual Texture Sample expression.

During this part of the graph, the RVT Asset is sampled and applies camera dependent or additional shading operations here. The RVT Asset attributes are samples and routed to the final Material output, so the less amount of work that is being done during this part of the graph, the cheaper the rendering for this material will be.

  1. Right-click and add a Runtime Virtual Texture Sample node.

    Click image for full size.

  2. Right-click and create another Make Material Attributes node. Connect the outputs of the Runtime Virtual Texturing Sample node to the corresponding inputs of the Make Material Attributes node.

    3_3_2_AddConnectMakeMatAttribute.png

  3. Connect the output of the Make Material Attributes node to the Yes input of the Virtual Texture Feature Switch node.

    Click image for full size.

  4. Select the Runtime Virtual Texture Sample node. In the Details panel, use the Virtual Textures Asset selection box to assign your RVT Asset you created earlier in this guide.

    3_3_4_AssignRVTAssetTOrvtSampleNode.png

  5. Connect the output of the Virtual Texture Feature Switch node to the input of the main Material Attributes node.

    3_3_5_VTFeatureSwitchTOmainAttributes.png

  6. Save and Close this Material.

Your material should now look like this:

Click image for full size.

4 - Placing a Runtime Virtual Texture Volume

Now that you've set up your material to support runtime virtual texturing, in this step, we will place a Runtime Virtual Texture Volume in our level. We will scale and rotate it to encompass our landscape using some built-in tools before assigning our RVT Asset to the volume.

  1. In the Modes panel, search for a Runtime Virtual Texture Volume under the Volumes category and drag it into the scene.

    Click image for full size.

  2. With the RVT Volume selected, you can use the Details panel to quickly scale and rotate the volume to encompass the bounds of a selected Actor.

    1. Under the Transform from Bounds category, use the Source Actor selection box to select an Actor that is placed in the level or use the eyedropper to select one.

      4_2_TransformFromBoundsSettings.png

    2. Click the Copy Bounds and Copy Rotation button to scale the RVT Volume to the bounds and rotation of the selected Actor.

      Any objects sampling from or writing to the RVT Asset should be inside the RVT Volume's bounds.

  3. Under the Virtual Texture category, assign your RVT Asset to the Virtual Texture asset selection box.

    4_3_AssignRVTAsset.png

If everything is set up correctly with the material M_LandscapeMaterial and it's correctly assigned and painted onto your Landscape terrain, the RVT Volume with the RVT Asset assigned should render correctly. If not, the material will render black (like the first image in this section of the guide).

4_0_RVTVolumeOutput.png

5 - Rendering Actors to a Runtime Virtual Texture

Now that your base Landscape material is set up and rendering to the RVT Asset, we can start to add other Actors in the world that we want to render to the RVT, too. In this step, we'll enable the Landscape spline— that represents the road—to Render directly onto the landscape through the RVT.

This part of the guide is using the Landscape spline already set up in Content Examples, however, the steps shown here can be applied to other Actors and their Materials. The spline is a practical example of a good use case for rendering to a runtime virtual texture.

  1. Navigate to the Modes panel and select the Landscape tab, and then select the Manage button.

    5_1_SelectLandscapeMode.png

  2. Under the Landscape Editor category, use the dropdown to select Edit Splines.

    5_2_SelectEditSplines.png

  3. In the Level Viewport, select any part of the spline. In the level Details, click the Segments button to select all segments that make up this spline.

    5_3_SelectSplineSegments.png

  4. Under the Landscape Spline Meshes category, expand the Spline Meshes array. The Static Mesh SM_Street should be assigned. Double-click on it to open the Static Mesh Editor.

    5_4_a_SplineStaticMesh.png

    Then under its Material Slots, double-click on Element 0 M_Street material to open it in the Material Editor.

    5_4_b_SplineStaticMeshMaterial.png

    For this Static Mesh and Material assigned, Element 0 was chosen because it's the base Material used for slot 0 and 1, with Element 1 being a child Material Instance of Element 0. Keep in mind that any Material that is to be rendered to the RVT Asset needs to be set up using the steps that follow.

  5. In the Material Editor with the Main Material node selected, under the Details panel, set the Material Domain to Virtual Texture.

    5_5_SplineMaterialSetup.png

  6. Save and Close both the Material and Static Mesh Editors.

  7. Back in the Level Viewport with your Landscape spline still selected, look in the Level Details panel under the Virtual Textures category. Click the add (+) button to add a new array element to the list. Assign your RVT Asset to this array element.

    5_6_SplineSetupAssignRVTAsset.png

In the Level Viewport, you should now see that the spline's material is rendered into the RVT Asset on the Landscape instead of floating along the spline path that is slightly above the terrain surface.

Without Runtime Virtual Texturing

With Runtime Virtual Texturing

Here's a closer look at the spline material being applied to the surface of the landscape using RVT.

Without Runtime Virtual Texturing

With Runtime Virtual Texturing

6 - On Your Own!

Now that you've worked through this guide and set up a Landscape material to use a Runtime Virtual Texture, you can start to explore applying your own Actor's materials to be rendered to the RVT. Use some of the suggestions below to get started:

  • Add a another Static Mesh to the RVT that can be applied like a decal. Look at how you can use a Static Mesh Plane with a masked material to add decal-like details to your terrain.

  • Use Foliage instances to paint meshes that can render to the RVT to create unique variations to your terrain.

  • Use multiple Runtime Virtual Texture Assets to manage different types of Actors and how they render to your Runtime Virtual Texture Volume.

  • Use the Translucency Sort Priority to set the layer order for how Actors are rendered to the RVT. For example, 0 would be the bottom layer and higher values would stack on top of another.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback