# 🎬 Landscape Caching for better Performance

## 🎬 [Creating the Runtime Virtual Textures](https://youtu.be/fYqTLRc02Kg?t=244)

{% hint style="info" %}
Virtual Texture Support needs to be enabled in your project.

See [Installation](https://sylvl.gitbook.io/panoramake-release/introduction/installation#enabling-virtual-textures-for-your-project) for info on how to set them up.
{% endhint %}

First, Create the **Runtime Virtual Textures** that will be used.\
**For Caching, at least the Color VT is mandatory for it to work,** other additional VTs may not be needed depending on your needs.

**Open the principal color VT and set its "Virtual Texture content" to "Base Color, Specular, Roughness, Normal".**\
**Recommended default values for the Sizes are 12-2-2.** &#x20;

**If you want to use VTs for World Height, open the one for it and set it to "World Height".**\
Recommended default values for the Sizes are 8-2-2. &#x20;

**If you want to use VTs for Nanite Displacement, open the one for it and set it to "Displacement".**\
Recommended default values for the Sizes are 10-2-2. &#x20;

![<- Color | Displacement for Nanite (5.4+) | Height ->
Good base values. ](https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FiEzfcqCgHUfy9tqY9USD%2FRvt1.png?alt=media\&token=b064f66e-3e6a-4341-8dcf-856cac4fdbeb)

Then, place Runtime Virtual Texture Volumes for each of the VTs in your world. \
In the Details panel, look for "Virtual Texture" and select the one you need, then click **Set Bounds**.

<figure><img src="https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FNKLK0a5IOX1YoON1K0US%2FRVT2.png?alt=media&#x26;token=1179c087-f972-4407-b2d1-a5e5293b0a1d" alt=""><figcaption><p>Correctly set VT Volume.</p></figcaption></figure>

Do that for each of the volumes you need.

Then, click on your Landscape, and add the Virtual Textures needed in the "Draw in Virtual Textures"  zone of its details as the screen below shows.

{% hint style="info" %}
If the Landscape is using **World Partition** you'll have to do this with the Landscape and all its Streaming Proxies selected (if on 5.1 or 5.2).

On 5.3+ you don't need to, you can set these values on the main Landscape and the proxies will follow it.
{% endhint %}

<figure><img src="https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FaL5WAdBdfV7OCBMJignB%2Fimage.png?alt=media&#x26;token=f5d8d7b3-cec9-4038-9114-a6c3d28d54df" alt=""><figcaption><p>End result.</p></figcaption></figure>

## Applying the Virtual Textures

Finally, In the Builder interface, enable the use of Virtual Texturing caching in the Global options.

<figure><img src="https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FFfCwPM4HMcmZ5AO3tkOn%2Fimage.png?alt=media&#x26;token=492497e6-f6e3-442b-9696-7f6531da42bd" alt=""><figcaption><p>The second "Disp" slot shows only if Nanite Tessellation is available and used.</p></figcaption></figure>

You can click the wand button to automatically select the Landscape's Virtual Texture, or select it manually by clicking its thumbnail.

![Make sure to select the good Virtual Texture if you select it manually.](https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FrNzJAAUWIpaGx5ljIzRN%2Fimage.png?alt=media\&token=3f06b7e6-5d1f-4c57-9f0f-500847fa2eab)

**Done !**\
Now your Instance can use Virtual Texture Caching to improve itsperformance !

![Cached](https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FpO3hhFOpP9kGEi4hOblJ%2Fimage.png?alt=media\&token=3761d25e-a2c7-4f20-8906-acd28512b4c4)

![Uncached](https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FzfjhmkPqwgSX6xqfkX8n%2Fimage.png?alt=media\&token=39cebb48-c542-4bd4-8b75-6654ba4a8248)

## Exclude Layers from caching

Caching works by setting the Instance fully static. But, some features do not work when cached.\
So, you can tick the "Exclude from Caching" option in the Material settings to keep a Sub-Layer uncached.

<figure><img src="https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FP3kV3y60WAVTABJCb1yM%2Fimage.png?alt=media&#x26;token=172f3059-3790-44c7-934a-8e77f66efe73" alt=""><figcaption></figcaption></figure>

These features cannot work when cached :

* Parallax Occlusion Mapping

However, other material features are taken into the caching when enabled and are as such free :

* Triplanar Mapping
* UV Tiling Variance

{% hint style="warning" %}
Uncaching a Layer has a great impact on shader complexity.

Even though only one Sub-Layer is uncached out of four for example, it's going to have something like more than half of the uncached shader complexity.

Still, it's better than keeping it uncached. Depending on your use case you may need to uncache some layers (Rocks far away for example.)
{% endhint %}

Uncaching the second Sub-Layer in our case for example gives us this shader complexity. As you can see, it's better than uncached but still negatively impacts the complexity.

![Partially uncached (one layer out of 3 is excluded. No extra features like UV Variance or distance-based are used.)](https://3751470283-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9KuznrlYB4kqrVq5qJMd%2Fuploads%2FafJlnHI1DYaK6KWj0bmB%2Fimage.png?alt=media\&token=0c12cb2c-532f-402c-abc6-b43cc432aaa6)
