FidelityFX Contrast Adaptive Sharpening 1.1
FidelityFX Contrast Adaptive Sharpening (CAS) is a low overhead adaptive sharpening algorithm with optional up-sampling. The technique is developed by Timothy Lottes (creator of FXAA) and was created to provide natural sharpness without artifacts.
Integration Guidelines
Sharpness
A float value controls the sharpening strength of CAS. You can pass the sharpness through FfxCasDispatchDescription::sharpness
to the ffxCasContextDispatch
function in ffx_cas.h
, in which the value will be packed into an internal constant buffer.
Sharpening Modes
In the CAS sample, there are three sharpening modes that can be selected:
-
Sharpening disabled.
-
Sharpening enabled, upsampling disabled.
-
Both sharpening and upsampling enabled.
You can also toggle the upscaling mode by yourself by setting FFX_CAS_SHARPEN_ONLY
in FfxCasContextDescription::flags
. If you want upsampling enabled, please don’t forget to set render and display resolution info in the FfxCasContextDescription
.
Color Space Conversion
CAS needs linear input color to perform correctly. If your color buffer is not in linear color space, you can set FfxCasContextDescription::colorSpaceConversion
to a color space supported in FfxCasColorSpaceConversion
to denote your input color space. CAS will perform color space conversion (if necessary) when loading or outputting color. It also ensures the output will be in the same color space as your input.
If you need to create a new color space conversion function, here’s how:
-
Create corresponding enum values inside
FfxCasColorSpaceConversion
andCasShaderPermutationOptions
. -
Add new branch inside the
POPULATE_PERMUTATION_KEY
macro inffx_cas_shaderblobs.cpp
. Please take the existing branches as reference. -
Add new pre-compiler branches inside the
casInput
,casOuput
,casInputHalf
andcasOutputHalf
functions inffx_cas_callbacks.glsl
orffx_cas_callbacks.hlsl
. Under these branches you should add your new color space conversion as needed.