FidelityFX Contrast Adaptive Sharpening

alt text

This sample demonstrates the use of the FidelityFX Contrast Adaptive Sharpening (CAS) post process effect.

For details on the techniques that underpin the CAS 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

Cas Options

Upsample, Sharpen, Off

If Off then disables use of contrast adaptive sharpening shader. If Upsample then CAS shader will sharpen and upsample from the selected ‘Render Dim’ to the display resolution as specified by the JSON configuration file (see above).

Cas Sharpness

0..1

Sliding left of right controls the amount of sharpening (0 – least amount, 1 – max amount).

Scale Preset

Ultra Quality, Quality, Balanced, Performance, Ultra Performance, Custom

Combo preset selection. Affect upscale ratio.

Custom Scale

1..3

Sliding left of right controls the amount of scaling (1 – least amount, 3 – max amount). Note that custom scale preset must be enabled to use the custom scale slider.

Setting up CAS

The Contrast Adaptive Sharpening (CAS) sample takes as input the color buffer produced by the geometry rendering passes, including the opaque, transparent, and sky box geometry, and also any post processing passes, but before any UI elements are rendered. The CAS shader also has some uniform parameter inputs const0 and const1 which are passed as input to the shader function CasFilter, which is defined in ffx_cas.h.

The value of these constants are computed either on the CPU (preferred) or the GPU by calling the function CasSetup, defined in the same file. The output of the CAS shader is an image of the same or larger dimensions as the input image. The valid dimensions for the output image is a function of the input image’s dimensions and can be determined by calling the function CasSupportScaling (see comments in ffx_cas.h for more details on all these functions).

The ffx_cas.h header file is designed to be included from both C++ and HLSL/GLSL via #define macros (see below).

C++:

Copied!

#define FFX_CPU
#include <gpu/ffx_core.h>
#include <gpu/ffx_cas.h>

HLSL:

Copied!

#define FFX_GPU
#define FFX_HLSL
#include "ffx_core.h"
#include "ffx_cas.h"

GLSL:

Copied!

#define FFX_GPU
#define FFX_GLSL
#include "ffx_core.h"
#include "ffx_cas.h"

Note that ffx_cas.h is dependent on ffx_core.h, so both must be included.

Shader options

The CAS shader or more specifically the CasFilter function has a few different options. One option is support for using 16-bit floating point (FP16) math versus 32-bit floating point (FP32) math. In general, FP16 math is more efficient than FP32 math on AMD hardware. Another option is the ability to produce upscaled output or to only sharpen the output without upscaling. For best performance, the sample compiles these options into the multiple shader permutations and chooses the specific permutations of the shader at runtime depending on the sample’s current configuration (see UI Elements section above). In all there are four permutations of the shader:

  • FP16-sharpen-only

  • FP16-sharpen-and-upscale

  • FP32-sharpen-only

  • FP32-sharpen-and-upscale

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!