Runtime Virtual Texturing

An overview of enabling and using Runtime Virtual Textures.

Windows
MacOS
Linux

A Runtime Virtual Texture (RVT) creates its texel data on-demand using the GPU at runtime and works similarly to traditional texture mapping. The RVT caches shading data over large areas making them a good fit for Landscape shading that uses decal-like materials and splines that are well-suited to conform to the terrain.

Workflow

Use the following high-level steps to setup and use runtime virtual texturing in your project:

  1. Create a Runtime Virtual Texture Asset(s) in the Content Browser. It is used to link all the components (Actors, RVT Volume, and RVT Materials) together to render the runtime virtual texture.

  2. Add a Runtime Virtual Texture Volume to the scene from the Modes panel. This is used to place the RVT Asset in the scene.

  3. Configure your Materials to write to the RVT Asset.

  4. Configure Materials to sample from the RVT Asset.

  5. Setup one or more Primitives or Landscape Actors to render to the RVT Asset.

For a step-by-step guide setting up RVT, see the

[Runtime Virtual Texturing Quick Start](Engine/Rendering/VirtualTexturing/HowTo/QS_RVT)
. In this guided, you'll set up a Landscape material and additional scene Actors to work with runtime virtual texturing.

Runtime Virtual Texturing Components

Use the following components to setup and work with runtime virtual textures in your Unreal Engine 4 (UE4) projects:

Runtime Virtual Texture Asset

The Runtime Virtual Texture Asset contains the configuration details that will be used when creating the RVT in the scene. Think of this as the linchpin in the RVT system that connects your Materials and Actors in the scene that are rendered to the RVT.

The RVT Asset is referenced by the following components:

  1. Each Runtime Virtual Texture Volume placed in the scene is assigned a single RVT Asset.

  2. Individual scene Actors are assigned any number of RVT Assets and when they are within the bounds of a volume that uses one of their assigned RVT Assets, they are rendered to the runtime virtual texture.

  3. Before an Actor is rendered to the RVT through the RVT Volume, its Materials must use the Virtual Texture Material Domain or use properly setup RVT Material Expressions.

Create a new RVT Asset from the Content Browser using the right-click context menu or the Add New button. Under the Materials & Textures category, select a Runtime Virtual Texture.

Click image for full size.

Double-click the Asset to open and configure its settings in its own Editor window:

RVT_Asset_Window.png

Use this window to define the size, tile size, type of Material Attributes supported by the runtime virtual texture.

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

Runtime Virtual Texture Volume

The Runtime Virtual Texture Volume is used to place the RVT Asset in the scene. This volume should encompass the Actor that it will render to when the Material is set up; generally, this should be a Landscape or surface terrain-like primitive.

Modes_RVTVolume.png

Any primitives sampling from, or writing to, the runtime virtual texture should be inside the bounds of the volume. When placing the RVT Volume, use the Transform from Bounds parameters in the Level Details panel to quickly position and scale the volume to a selected Actor. Typically, this would be something like a Landscape in your scene.

  1. From the Modes panel, drag in a Runtime Virtual Texture Volume to the scene.

  2. With the volume selected, Use the level Details panel to locate the Transform from Bounds category and use the Source Actor asset selection or the eye dropper to select an Actor in the scene.

  3. Use the Copy Rotation and Copy Bounds buttons to quickly position, scale, and rotate the volume.

Objects that render to the RVT are rendered using an Orthographic projection in the Negative-Z direction of the RVT Volume.

Runtime Virtual Texture Material Expressions

For scene Actors that are assigned an RVT Asset, their Materials must be setup to enable the following actions:

  • Setting the Material Domain to Virtual Texture which requires no additional setup and enables the Actor to be written to the RVT in the scene.

  • Adding Material logic that enables write to and sample from the RVT Asset enabling objects to be composited into the final RVT in the scene.

Material Domain: Virtual Texturing

Use the Details panel to set your the Material Domain to Virtual Texture to render it to an RVT in the scene:

RVT_1_MaterialDomainVT.png

The Main Material node is used to write to any bound RVT in the scene that uses the same RVT Asset assigned to an RVT Volume and the scene Actor. No additional setup is required to render the Material or Actor to the RVT in the scene.

Writing to and Sampling from the Runtime Virtual Texture

To write to and sample from an RVT in your scene, you must first setup some RVT expressions to handle this for your material:

  • The Runtime Virtual Texture Output expression is used to define a single material that both writes to and samples the virtual texture. Existing material logic should be plugged into this node.

    Mat_RVTOutput.png

  • The Runtime Virtual Texture Sample expression takes in the assigned RVT Asset to sample and outputs that for this material.

    Mat_RVTSample.png

This is an example Landscape material that writes to and samples the bound RVT Asset. It also uses logic to fall back to traditional landscape rendering when a platform doesn't support Virtual Texturing:

Click image for full size.

Additional Material Expressions

Materials are compiled in one of two contexts for use with RVT:

  • To render to the RVT

  • To render to other passes

The Runtime Virtual Texture Replace expression is ideal when wanting part of your material logic to render to the RVT.

Mat_RVTReplace.png

The View Property expression also has a couple of RVT-specific options:

  • The Virtual Texture Output Level node outputs the RVT mip level currently being rendered.

    Mat_ViewPropertyVTOutputLevel.png

  • The Virtual Texture Output Derivative node outputs the X and Y size of world space covered by a single texel of the current virtual texture output.

    Mat_ViewPropertyVTOutputDerivative.png

An example use case of these expressions would be to mimic the use of some distance-based shading in the RVT. Because RVT shading is camera-independent, this type of shading cannot be expressed directly. However, something similar is achievable by making the shading mip level-dependent. The Runtime Virtual Texture Replace node can be used to implement a mip level-dependent shading path only for the Runtime Virtual Texture Output node.

The Virtual Texture Feature Switch is useful when setting up material logic to fallback to an alternative path when virtual texturing is not supported.

Scene Actor Output Properties

Any Actor placed in the scene can render to an RVT. The following Actor-types are good candidates:

Ideal Actor Candidates

Non-Ideal Actor Candidates

  • Landscape and Landscape Splines

  • Static Meshes and Instanced Static Meshes

  • Foliage Instances (for decal scattering)*

  • Skeletal Meshes

  • Movable Static Meshes

  • Animated Meshes

Because RVT content is effectively a shading cache, it isn't fully updated every frame, meaning that the objects rendered to it are expected to have their mobility be Static. Skinned and animated primitives are not good candidates for rendering to an RVT.

On each Actor, use the Details panel to specify which RVT that Actor should render to. An Actor can be assigned to more than one RVT.

Use the Render to Virtual Textures array in the Actor Details panel to specify which RVT Assets it can render to in the scene. An actor can be assigned to multiple RVTs. Rendering to an RVT only happens when the RVT Asset has been assigned to a placed RVT Volume in the scene and once the Actor's Materials have been set up correctly.

See the

[Runtime Virtual Texture Quick Start](Engine/Rendering/VirtualTexturing/HowTo/QS_RVT)
for an example. Also see the [TODO MATERIAL REFERENCE] =========TODO==========TODO=========TODO===========.

Use the sections that follow to further Actor behavior when rendering to an RVT in the scene:

Virtual Texture Pass Type

Use the Virtual Texture Pass Type selection to control how Landscapes and Primitives render for your project with regards to virtual texturing. Sometimes, it's necessary for the Main Pass to change if a Primitive is rendered to an RVT or when the project is required to run on a platform that doesn't support virtual texturing.

These options enable you to control object rendering to an RVT:

RVT_Actor_RVTAsset_PassType.png

Selection

Description

Virtual Texture Only

Never render this Actor in the Main Pass and if there is no RVT in the scene, it will not render at all. This option should be used for items that aren't necessary (such as decal-type materials) when there is no virtual texture support. For example, using a Static Mesh plane with a material outputting to an RVT will write the material like a decal to the RVT landscape material. If a platform or feature level doesn't support virtual texturing, the Static Mesh plane would not render to the Main Pass.

Virtual Texture OR Main Pass

Renders the Actor to either the RVT or the Main Pass depending on virtual texture support. For example, a Landscape spline rendering a road mesh and material should write to the RVT to apply its material along the spline. However, if there is no valid RVT in the scene or there is no feature level support for virtual texturing, the spline road mesh will still be visible on the Landscape.

Virtual Texture AND Main Pass

Renders the Actor to the RVT and in the Main Pass regardless of virtual texture support. This is ideal for objects (such as a Landscape) that need to both write to and sample from the RVT. For example, a Landscape material that is setup to both write data to the RVT and render the final RVT should always be visible.

It's recommended to disable shadow casting and collision for primitives being rendered to an RVT. These are not automatically disabled.

Setting LOD and Mips

Use the Virtual Texture Advanced rollout properties to control how Actors render to the RVT by setting level of detail (LOD) and culling behavior. Access these parameters from the Actor's level Details panel:

For Primitives in the scene, adjust the following properties:

RVT_Actor_LODSettings.png

Property

Description

Virtual Texture LOD Bias

This sets the LOD to render into the RVT. It is selected automatically based on how much of the virtual texture page the rendered primitive covers. A further bias can be applied using this option. Higher values will force a lower detailed LOD to be used.

Virtual Texture Skip Mips

This is the number of lowest mips in the RVT to skip rendering this primitive. This option removes the cost of rendering into the RVT if it is known that a primitive doesn't need to be rendered beyond some set draw distance.

Virtual Texture Min Coverage

If this value is set, the Virtual Texture Skip Mips parameter is ignored and instead cull the primitive from an RVT mip based on its estimated projected size in the mip. This value is in units of pixels but in log space. For example, setting a value of 3 will cull a primitive if its projected size is less than 8 pixels.

For Landscapes in your scene, adjust the following properties:

RVT_Actor_Landscape_LODSettings.png

Property

Description

Virtual Texture Num LODs

The number of LODs used to render Landscape components into the RVT. A setting of 0 means that each landscape component is rendered into the RVT as a single quad. A setting of 0 is optimal for the GPU. Higher values are required if the Landscape Material requires high frequency vertex interpolated data.

Virtual Texture LOD Bias

A bias applied to the selected LOD for rendering to the RVT.

Object Sort Priority

Rendering multiple primitives to the RVT in the scene presents the potential problem for object layer sorting. Since Z-buffering isn't used and the Actor's material can have alpha blending, it means that the sort order may need to be defined.

Use the level Details panel for any selected Actor in the scene to set its Translucency Sort Priority.

RVT_Actor_TranslucenySortPriority.png

All Actors have a default value of 0. Smaller values always render first (or on the bottom layer) and larger ones render last (or on top).

Translucency Sort Priority | Spline: 1 | Decal: 0

Translucency Sort Priority | Spline: 1 | Decal: 2

The render order of Actors with the same value is undefined. If an Actor is missing from the RVT in your scene, check the Translucency Sort Priority first.

Optimizations, Statistics, and Debugging

Use the following sections to explore ways to optimize and debug runtime virtual texturing in your projects:

Stats

Open the console using the backtick (`) key and enter the following commands to enable their stats information:

Use stat virtualtexturing to give you feedback about the virtual texturing scene for cost in milliseconds (ms) and counters for page tables.

Stat_VirtualTexturing.png

Use stat virtualtexturememory to display relevant memory counters related to the use of virtual texturing in the current scene.

Stat_VirtualTextureMemory.png

Memory

The Memory Pool Sizes for virtual texturing are setup in the BaseEngine.ini configuration file. The pools are setup per-texture compression format and tile size. Configuration of the pool size is driven by specifying the maximum memory budget for your project. You'll find these settings under the [/Script/Engine.VirtualTexturePoolConfig].

When setting your own values, a good starting configuration is using a tile size of 128 or 256 with a border of 4 texels, like this example:

[/Script/Engine.VirtualTexturePoolConfig]
+Pools=(SizeInMegabyte=36, TileSize=136, Format=PF_DXT1)
+Pools=(SizeInMegabyte=72, TileSize=136, Format=PF_BC5)
+Pools=(SizeInMegabyte=72, TileSize=136, Format=PF_DXT5)
+Pools=(SizeInMegabyte=34, TileSize=264, Format=PF_DXT1)
+Pools=(SizeInMegabyte=68, TileSize=264, Format=PF_BC5)
+Pools=(SizeInMegabyte=68, TileSize=264, Format=PF_DXT5)

This configuration translates to pools of 64x64 128-size tiles, or 32x32 256 size tiles at a cost of approximately 100 megabytes (mb).

Only one of the BC5 and DXT5 pool will be used according to RVT content type.

When configurating virtual texturing physical memory pools, use the stat virtualtexturing command to show dynamic use of the virtual texturing system, including cache loads. Additionally, enter the command r.VT.ListPhysicalPools to dump a lot of information about the virtual texturing system state to the output log.

Debugging

Use the following console variables for debugging virtual texturing in your project:

Console Variable

Description

r.VT.Flush

Use this command to flush all of the physical caches in the Virtual Texturing system. It can be useful when you suspect an issue that could be caused by a bad cache invalidation.

r.VT.MaxUploadsPerFrame

Use this command to set the maximum number of page uploads per-frame (default is 64). It can be useful when you want to throttle the number of Runtime Virtual Texture Tiles being updated in a frame to prevent performance spikes.

Additional Notes and Limitations

  • In Unreal Engine 4.23, Mobile platforms are not currently supported.

  • RVT currently supports up to 256 KiTexels

  • In a future release, we may add support to combine streaming and runtime virtual texturing. It could be more efficient to bake and stream low-resolution mips of an RVT while still rendering the high-resolution mips at runtime.

  • In a future release, we may include additional RVT content types and add height layer for displacement mapping.

Select Skin
Light
Dark

새로운 언리얼 엔진 4 문서 사이트에 오신 것을 환영합니다!

문서 사이트에 대한 의견을 모을 수 있는 피드백 시스템을 포함해서 여러가지 새로운 기능을 준비하고 있습니다. 아래 Documentation Feedback 포럼(영문) 또는 언리얼 엔진 네이버 공식 카페(한글) 중 편하신 곳에 의견이나 문제점을 알려 주세요.

새 시스템이 준비되면 알려 드리겠습니다.

네이버 카페
공식 포럼