FidelityFX Variable Shading
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 |
|
Enable/Disable Variable Shading. |
PerDraw VRS |
|
Shading rate value. Additional shading rates are 2×4, 4×2, 4×4. |
ShadingRateImage Enabled |
|
Enable/Disable Tier 2 VRS control image. |
ShadingRateImage Combiner |
|
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 |
|
Defines a value against which luminance variance gets compared in the compute shader generating the VRS image. |
VRS Motion Factor |
|
Sets a factor by which the motion of the pixel since the last frame gets scaled to modify the shading rate. |
ShadingRateImage Overlay |
|
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++:
Create VRS context:
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:
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 .