Up to date

This page is up to date for Godot 4.1. If you still find outdated information, please open an issue.

Variable rate shading

What is variable rate shading?

In modern 3D rendering engines, shaders are much more complex compared to before. The advent of physically-based rendering, real-time global illumination and screen-space effects has increased the number of per-pixel shading that must be performed to render each frame. Additionally, screen resolutions also have increased a lot, with 1440p and 4K now being common target resolutions. As a result, the total shading cost in scene rendering usually represents a significant amount of the time taken to render each frame.

Variable rate shading (VRS) is a method of decreasing this shading cost by reducing the resolution of per-pixel shading (also called fragment shading), while keeping the original resolution for rendering geometry. This means geometry edges remain as sharp as they would without VRS. VRS can be combined with any 3D antialiasing technique (MSAA, FXAA, TAA, SSAA).

VRS allows specifying the shading quality in a local manner, which makes it possible to have certain parts of the viewport receive more detailed shading than others. This is particularly useful in virtual reality (VR) to achieve foveated rendering, where the center of the viewport is more detailed than the edges.

Here's a scene rendered with rate shading disabled then enabled, using the density map linked at the bottom of this page:

Variable rate shading disabled in textured scene

Variable rate shading disabled in textured scene

Variable rate shading enabled in textured scene (lower quality but higher performance)

Variable rate shading enabled in textured scene (lower quality but higher performance)

When used in scenes with low-frequency detail (such as scenes with a stylized/low-poly aesthetic), it's possible to achieve similar performance gains but with less reduction in visual quality:

Variable rate shading disabled in untextured scene

Variable rate shading disabled in untextured scene

Variable rate shading enabled in untextured scene (lower quality but higher performance)

Variable rate shading enabled in untextured scene (lower quality but higher performance)

Hardware support

Variable rate shading is only supported on specific GPUs:

Desktop:

  • NVIDIA Turing and newer (including GTX 1600 series)

  • AMD RDNA2 and newer (both integrated and dedicated GPUs – including Steam Deck)

  • Intel Arc Alchemist and newer (dedicated GPUs only)

    • Intel integrated graphics do not support variable rate shading.

Mobile SoCs:

  • Snapdragon 888 and newer

  • MediaTek Dimensity 9000 and newer

  • ARM Mali-G615 and newer

As of January 2023, Apple and Raspberry Pi GPUs do not support variable rate shading.

Using variable rate shading in Godot

Note

Both Forward Plus and Forward Mobile rendering methods support variable rate shading. VRS can be used in both pancake (non-XR) and XR display modes.

The Compatibility rendering method does not support variable rate shading.

In the advanced Project Settings, the Rendering > VRS section offers settings to control variable rate shading on the root viewport:

  • Mode: Controls the variable rate shading mode. Disabled disables variable rate shading. Texture uses a manually authored texture to set shading density (see the property below). XR automatically generates a texture suited for foveated rendering in virtual/augmented reality.

  • Texture: The texture to use to control shading density on the root viewport. Only used if Mode is Texture.

For custom viewports, the VRS mode and texture must be set manually to the Viewport node.

Note

On unsupported hardware, there is no visual difference when variable rate shading is enabled. You can check whether hardware supports variable rate shading by running the editor or project with the --verbose command line argument.

Creating a VRS density map

If using the Texture VRS mode, you must set a texture to be used as a density map. Otherwise, no effect will be visible.

You can create your own VRS density map manually using an image editor, or generate it using another method (e.g. on the CPU using the Image class, or on the GPU using a shader). However, beware of performance implications when generating a VRS image dynamically. If opting for dynamic generation, make sure the VRS image generation process is fast enough to avoid outweighing the performance gains from VRS.

The texture must follow these rules:

  • The texture must use a lossless compression format so that colors can be matched precisely.

  • The following VRS densities are mapped to various colors, with brighter colors representing a lower level of shading precision: