FidelityFX Variable Shading

alt text

This sample demonstrates the use of the FidelityFX Variable Shading (VRS) compute algorithm.

For details on the techniques that underpins the Variable Shading effect you can refer to the respective technique documentation .

Requirements

  • Windows

  • DirectX(R)12

  • Vulkan(R)

UI elements

The sample contains various UI elements to help you explore the techniques it demonstrates. The table below summarises the UI elements and what they control within the sample.

Element name

Value

Description

Enable Variable Shading

Checked/Unchecked

Enable/Disable Variable Shading.

PerDraw VRS

1x1, 1x2, 2x1, 2x2

Shading rate value. Additional shading rates are 2×4, 4×2, 4×4.

ShadingRateImage Enabled

Checked/Unchecked

Enable/Disable Tier 2 VRS control image.

ShadingRateImage Combiner

Checked/Unchecked

The options for each combiner are: passthrough the previous state (i.e. disable the current stage), override (ignore previous stages), min, max and sum.

VRS variance Threshold

0.0 - 1.0

Defines a value against which luminance variance gets compared in the compute shader generating the VRS image.

VRS Motion Factor

0.0 - 1.0

Sets a factor by which the motion of the pixel since the last frame gets scaled to modify the shading rate.

ShadingRateImage Overlay

Checked/Unchecked

Enable/Disable ShadingRateImage overlay, a debug image over the rendered scene.

Setting up Variable Shading

The Variable Shading compute shader takes as input the linear color buffer produced by the geometry rendering passes, and motion vectors buffer produced before geometry rendering passes. Final VRS control image is written to output buffer passed from setup.

Include the interface for the backend of the VRS API.

C++:

Copied!

#include <FidelityFX/host/ffx_vrs.h>

Create VRS context:

Copied!

if (m_AllowAdditionalShadingRates)
    m_InitializationParameters.flags |= FFX_VRS_ALLOW_ADDITIONAL_SHADING_RATES ;

m_InitializationParameters.shadingRateImageTileSize = m_FeatureInfoVRS.MaxTileSize[0];
ffxVrsContextCreate (&m_VRSContext, &m_InitializationParameters);

Set up dispatch parameters and dispatch:

Copied!

FfxVrsDispatchDescription  dispatchParameters = {};
dispatchParameters.commandList                = ffxGetCommandList (pCmdList);
...
FfxErrorCode errorCode = ffxVrsContextDispatch (&m_VRSContext, &dispatchParameters);

Sample controls and configurations

For sample controls, configuration, and FidelityFX Cauldron Framework UI element details, see Running the samples .

See also

Related pages

  • Visit the FidelityFX SDK product page for download links and more information.

Looking for more documentation on GPUOpen?

AMD GPUOpen software blogs

Our handy software release blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.

GPUOpen Manuals

Don’t miss our manual documentation! And if slide decks are what you’re after, you’ll find 100+ of our finest presentations here.

AMD GPUOpen Performance Guides

The home of great performance and optimization advice for AMD RDNAâ„¢ 2 GPUs, AMD Ryzenâ„¢ CPUs, and so much more.

Getting started: AMD GPUOpen software

New or fairly new to AMD’s tools, libraries, and effects? This is the best place to get started on GPUOpen!

AMD GPUOpen Getting Started Development and Performance

Looking for tips on getting started with developing and/or optimizing your game, whether on AMD hardware or generally? We’ve got you covered!

AMD GPUOpen Technical blogs

Browse our technical blogs, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan®, DirectX®, Unreal Engine, and lots more.

Find out more about our software!

AMD GPUOpen Effects - AMD FidelityFX technologies

Create wonder. No black boxes. Meet the AMD FidelityFX SDK!

AMD GPUOpen Samples

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

AMD GPUOpen developer SDKs

Discover what our SDK technologies can offer you. Query hardware or software, manage memory, create rendering applications or machine learning, and much more!

AMD GPUOpen Developer Tools

Analyze, Optimize, Profile, Benchmark. We provide you with the developer tools you need to make sure your game is the best it can be!