Fidelityfx Cas: Lou Kramer, Developer Technology Engineer, Amd
Fidelityfx Cas: Lou Kramer, Developer Technology Engineer, Amd
Fidelityfx Cas: Lou Kramer, Developer Technology Engineer, Amd
Overview
Algorithm
Integration
Input
Performance
Examples
Q&A
No CAS
CAS
Created to provide natural sharpness without artifacts with only low overhead
Created to provide natural sharpness without artifacts with only low overhead
Sharpening + Scaling
⁃ As a Dynamic Resolution Scaling option
Everytime when you think it improves image quality Best is to just try it out!
It uses the minimal nearest 3x3 source texel window for filtering.
w
Final filter is of form while the centre pixel is the output pixel.
w 1 w
w
CAS fetches a ‘circle‘ neighborhood around the pixel ‘c‘. Middle color: 0.9, 0.4, 0.1
a Dark color: 0.75, 0.25, 0.05
b c d
e
The minimum and maximum give an idea of local contrast. Only the green channel is used.
d_max_g is the minimum distance to the signal limit, since d_max_g < d_min_g.
d_max_g is divided by MAX_G to get a base sharpening amount of ‘A‘
d_min_g is not used in this example, but for darker colors it would since then we have d_max_g >
d_min_g.
Influences
// The 'varAU4(const0);' expands into 'uint32_t const0[4];' onthe
thepeak
CPU.
// The 'varAU4(const0);' expands into 'uint4 const0;'sharpness amount.
on the GPU.
varAU4(const0);
varAU4(const1);
CasSetup(const0,const1,
0.0f, // Sharpness tuning knob (0.0 to 1.0).
1920.0f,1080.0f, // Example input size.
2560.0f,1440.0f); // Example output size.
Example: sharpness_knob = 0
developerMaximum = Lerp(-0.125, -0.2, 0) = -0.125;
Example: sharpness_knob = 0
developerMaximum = Lerp(-0.125, -0.2, 0) = -0.125;
W = A * developerMaximum;
W = 0.577350 * -0.125 ≈ -0.072169
w a -
The filter kernel is then: w 1 w b c d 0.07216
9
w e
- 1 -
0.07216 0.07216
output_color = (w*a + w*b + 1*c + w*d + w*e) / (w * 4 + 1);
9 9
-
0.07216
9
It starts by fetching the ‘circle’ neighborhood around the pixel centered between centers of pixels
{f,g,j,k}
The algorithm then computes the no-scaling sharpening weights {wf, wg, wj, wk} for {f,g,j,k}.
b c
e f g h
i j k l
n o
// s t
pp := fractional pixel position
// u v
float s = (1.0f – pp.x) * (1.0f – pp.y);
float t = pp.x * (1.0f – pp.y);
float u = (1.0f – pp.x) * pp.y;
float v = pp.x * pp.y;
s = s * contrastWeight_f
t = t * contrastWeight _g
b c
u = u * contrastWeight _j
e f g h
v = v * contrastWeight _k
i j k l
n o
The green channel is used as a proxy for „luma“.
wf * s wg * t b c
wf * s wg * t + wj * u wf * s + wk * v wg * t e f g h
+s +t
i j k l
wj * u wf * s + wk * v wg * t + wj * u wk * v
+u +v n o
wj * u wk * v
General recommendation – after your post process chain and before your UI
Bloom and
Anti-
Tone CAS Grain
Aliasing
mapping
Bloom and
Anti-
Tone CAS Grain
Aliasing
mapping
Here is an example for running with the 16x16 (4-way unroll for 32-bit or 2-way unroll for 16-bit)
vkCmdDispatch(cmdBuf,(widthInPixels+15)/16,(heightInPixels+15)/16,1);
relies on how you distribute the workload to your threadgroups. If in any doubt, refer to the example
Pass takes an image + constants and outputs sharpened, potentially higher resolution image
CAS
Compute
Shader
Constant
s
Pass takes an image + constants and outputs sharpened, potentially higher resolution image
CAS
Compute
Shader
Include this CAS header file (or copy it in without an include). HLSL:
ASU2 := int2
#include <ffx_cas.h>
AF1 := float
AF3 := float3
Filter.
…
Filter.
…
Filter.
…
< 100 µs
84
Unity Demo
85
Strange
Brigade
86
Strange
Brigade
87
Strange
Brigade
3840 native
88
THANKS TO
Timothy Lottes
Adam Sawicki
Marcus Svensson
Ihor Szlachtycz
Nick Thibieroz
89
Q&A
lou.kramer@amd.com
@lou_auroyup
https://gpuopen.com/
The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors.
The information contained herein is subject to change and may be rendered inaccurate for many reasons, including but not limited to product and roadmap changes,
component and motherboard version changes, new model and/or product releases, product differences between differing manufacturers, software changes, BIOS
flashes, firmware upgrades, or the like. AMD assumes no obligation to update or otherwise correct or revise this information. However, AMD reserves the right to
revise this information and to make changes from time to time to the content hereof without obligation of AMD to notify any person of such revisions or changes.
AMD MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTS HEREOF AND ASSUMES NO RESPONSIBILITY FOR ANY INACCURACIES, ERRORS
OR OMISSIONS THAT MAY APPEAR IN THIS INFORMATION.
AMD SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AMD BE LIABLE TO
ANY PERSON FOR ANY DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF ANY INFORMATION CONTAINED HEREIN, EVEN
IF AMD IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
ATTRIBUTION
© 2019 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo, Radeon TM and combinations thereof are trademarks of Advanced Micro
Devices, Inc. in the United States and/or other jurisdictions. Vulkan is a registered trademark of the Khronos Group Inc. Other names are for informational
purposes only and may be trademarks of their respective owners.