CasCmdLine – Testing AMD FidelityFX Contrast Adaptive Sharpening with the Command Line

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on email

CasCmdLine is a simple, command-line Windows® program included in the AMD FidelityFX CAS repository in binary and source form. It lets you test the effect on image files such as screenshots from your game.

The usage is very simple. If you have a screenshot from your game saved as an image file (PNG, JPG, or BMP) just open Windows® Terminal (Command Prompt). Then launch the program with parameters specifying the name of the source file to read and the target file to write, for example:

CasCmdLine.exe MyGame-01.png MyGame-01_CAS.png

Then you will be able to see how our Contrast Adaptive Sharpening algorithm would affect your game by comparing the two images.

AMD FidelityFX CAS can not only do sharpening, but also optionally upscale the resolution in a single pass. You can test this feature by specifying additional options at the beginning of the command line.

For example, if your source image is 1920 x 1080, you can see how upscaling to 2560 x 1440 with sharpening would look like by issuing a command:

CasCmdLine.exe -Scale 2560 1440 MyGame-01.png MyGame-01_ScaledCAS.png

If you want to compare the result with a simpler upscaling algorithm and see how much difference AMD FidelityFX CAS introduces, use an additional parameter -Mode to choose a different algorithm.

  • NearestNeighbor – your result will then look pixelated.
  • Linear – to use linear interpolation – your result will look blurry.

For example:

CasCmdLine.exe -Scale 2560 1440 -Mode Linear MyGame-01.png MyGame-01_ScaledLinear.png

The CAS algorithm also lets you control the level of sharpness, in the range 0..1 . 0 does not mean there’s no sharpening, but rather it’s the default. You can request extra sharpness by increasing this parameter. Use command line argument -Sharpness to specify it.

For example:

CasCmdLine.exe -Sharpness 0.7 MyGame-01.png MyGame-01_CAS.png

The tool offers additional features for advanced users. It performs gamma correction by default – assumes the image is saved with sRGB gamma encoding, converts the pixels to linear space while AMD FidelityFX CAS is being applied, and then back to sRGB before saving.

If you want to work on a dump of some intermediate texture from inside of your engine which is stored in linear space, use parameter -Linear to disable the gamma correction.

You can also increase the precision of processing by specifying -FP16 parameter. The program will then use R16G16B16A16_FLOAT texture format. By default, it is R8G8B8A8_UNORM.

Using such high precision requires an appropriate file format. CasCmdLine supports also DDS files, which can store textures in high precision.

Full documentation of the command line syntax can be seen by launching the program without any parameters.

The tool is open source, based on the MIT license. The source is a short Microsoft® Visual Studio project written in C++ that uses Windows® Imaging Component (WIC) to load and save images and initializes Direct3D® 11 (without any window or swapchain) to launch AMD FidelityFX CAS. It may also serve as an example of AMD FidelityFX CAS integration.

Related content

Adam Sawicki
Adam works in the European Game Engineering team, primarily on Vulkan® and Direct3D®12 games technology and the games that use it. Links to third party sites, and references to third party trademarks, are provided for convenience and illustrative purposes only. Unless explicitly stated, AMD is not responsible for the contents of such links, and no third party endorsement of AMD or any of its products is implied.

You may also like...

Some light reading to take away with you. Our ISAs, manuals, whitepapers, and many more.

Explore our huge collection of detailed tutorials, sample code, presentations, and documentation to find your answers to your graphics development questions.

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

Browse all our fantastic tutorials, including programming techniques, performance improvements, guest blogs, and how to use our tools.