---
id: "contrast-adaptive-sharpening"
title: "Contrast Adaptive Sharpening"
aliases: [CAS]
domain: "post"
stage: "post"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal]
year_introduced: 2019
inputs: [ldr-image]
outputs: [ldr-image]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "GPUOpen-Effects, 2020"
url: "https://texelatlas.vercel.app/t/contrast-adaptive-sharpening/"
sources_verified_at: "2026-11-29"
---
# Contrast Adaptive Sharpening (GPUOpen-Effects, 2020)

> A cheap sharpening filter that scales its strength per pixel by local contrast, so already-crisp edges are not over-sharpened while soft areas are lifted, avoiding most of the halos of a plain unsharp mask.

## Reach for it when

- image looks soft after upscaling or taa
- sharpen the frame without halos or noise boosting
- cheap sharpening pass that avoids ringing on edges
- taa blur makes the image mushy

## How it works

CAS reads a plus-shaped neighbourhood of five pixels. It computes the per-channel min and max of the neighbourhood and derives a sharpening amount inversely related to the headroom between those extremes and the representable range: a pixel with plenty of headroom sharpens more, a pixel near 0 or 1 sharpens less. This amount sets a negative lobe weight for the four neighbours, and the output is the normalised weighted sum of the centre and neighbours, clamped to the neighbourhood range. Because the weight adapts to local contrast, the filter stays stable in high-contrast regions where a fixed kernel would ring. It operates on LDR display-referred values and can be fused with upscaling.

## When to use it

Choose it as a final pass after TAA or an upscaler to restore crispness lost to history blur.

Prefer built-in sharpening inside [AMD FidelityFX Super Resolution](https://texelatlas.vercel.app/t/fidelityfx-super-resolution.md) or [NVIDIA DLSS](https://texelatlas.vercel.app/t/dlss.md) when those already apply one, to avoid double sharpening. Prefer no sharpening for stylized flat-shaded content.

## Cost

cheap — One full-screen pass with five fetches; negligible next to TAA.
Measured GPU Weight: 14.58× baseline (moderate) — 0.4796 ms median / 0.4924 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 11.23× baseline (moderate) — 0.1785 ms median (2.69× faster on L4).
Ampere A100 scaling: 9.21× baseline (moderate) — 0.2653 ms median (1.81× faster on A100).

## Failure modes

- Amplifies noise and film grain if applied after grain
- Halos remain around very high-contrast edges at high strength
- Sharpening after tonemapping clips highlights in already bright regions
- Exaggerates aliasing in unfiltered scenes

## Engine support

- godot: builtin — `Viewport.scaling_3d_mode = SCALING_3D_MODE_FSR (FSR 1.0 RCAS sharpening via fsr_sharpness)` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Viewport.xml, checked 2026-12-01)
- threejs: official — `import { sharpen } from 'three/addons/tsl/display/SharpenNode.js'` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/tsl/display/SharpenNode.js, checked 2026-12-01) — Implements RCAS, the FidelityFX CAS derivative.
- unity: builtin — `HDRP Asset > Dynamic Resolution > Upscale Filter = Contrast Adaptive Sharpen (CAS)` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Documentation~/Dynamic-Resolution.md, checked 2026-12-01) — HDRP only, as a dynamic-resolution upscale filter.
- unreal: builtin — `Temporal Super Resolution (TSR) and r.Tonemapper.Sharpen post-upscaling sharpening` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/temporal-super-resolution-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: ldr-image
- Outputs: ldr-image
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal

## Presets

### Left: softened image. Right: CAS, a 5-tap cross whose strength is scaled by local min/max contrast (glsl-fragment; rendered 2026-11-29)

```json
{
  "SHARP": 1
}
```

```glsl
float hash(vec2 c){uvec2 u=uvec2(ivec2(floor(c)));uint h=u.x*1597334673u^u.y*3812015801u;h^=h>>15;h*=2246822519u;h^=h>>13;h*=3266489917u;h^=h>>16;return float(h)*(1./4294967296.);}
float lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}
vec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}
vec3 img(vec2 p){
  vec3 c=mix(vec3(.12,.18,.34),vec3(.95,.72,.45),clamp(p.y+.5,0.,1.));
  vec2 q=p-vec2(-.03,.14); float rr=.16; float d=length(q)-rr;
  vec3 n=normalize(vec3(q/rr,sqrt(max(1.-dot(q,q)/(rr*rr),0.))));
  float l=clamp(dot(n,normalize(vec3(-.5,.6,.6))),0.,1.);
  c=mix(c,vec3(.85,.26,.2)*(.18+.9*l),smoothstep(.002,-.002,d));
  vec2 r=p-vec2(0.,-.2);
  if(abs(r.x)<.2&&abs(r.y)<.09) c=mix(vec3(.1,.35,.3),vec3(.93,.92,.85),smoothstep(-.3,.3,sin(r.x*340.+r.y*90.)));
  if(p.y<-.34&&p.y>-.42){ vec3 h=.5+.5*cos(6.2832*((p.x+.25)*2.+vec3(0.,.33,.67))); c=h; }
  c=mix(c,vec3(.97,.85,.2),smoothstep(.003,-.003,abs(p.x-.17)-.025)*step(.0,p.y)*step(p.y,.4));
  return c;
}

const float SHARP=1.0; // P
vec3 soft(vec2 p){float e=2.2/512.;return .25*(img(p+vec2(e,e))+img(p+vec2(-e,e))+img(p+vec2(e,-e))+img(p+vec2(-e,-e)));}
void mainImage(out vec4 fragColor,in vec2 fragCoord){
  vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;vec2 q=vec2(uv.x+(R?-.25:.25),uv.y);
  vec3 col=soft(q);
  if(R){float e=1./512.;
    vec3 b=soft(q+vec2(0.,e)),d=soft(q-vec2(e,0.)),f=soft(q+vec2(e,0.)),h=soft(q-vec2(0.,e)),c=col;
    vec3 mn=min(min(min(d,c),min(f,b)),h),mx=max(max(max(d,c),max(f,b)),h);
    vec3 amp=sqrt(clamp(min(mn,1.-mx)/max(mx,1e-3),0.,1.));
    vec3 w=-amp/mix(8.,5.,SHARP);
    col=(w*(b+d+f+h)+c)/(1.+4.*w);}
  if(abs(uv.x)<.0015)col=vec3(1.);fragColor=vec4(clamp(col,0.,1.),1.);
}
```

Attribution: written for this index

## Combines with

- [Temporal Anti-Aliasing](https://texelatlas.vercel.app/t/temporal-anti-aliasing.md): Run after the TAA resolve to counter its blur.

## Sources

1. [primary] GPUOpen-Effects (2020) GPUOpen-Effects/FidelityFX-CAS. https://github.com/GPUOpen-Effects/FidelityFX-CAS License: MIT. (verified via github on 2026-11-29)
2. [tutorial] AMD GPUOpen FidelityFX Contrast Adaptive Sharpening. gpuopen.com. https://gpuopen.com/fidelityfx-cas (verified via http on 2026-11-29)

## Cite this entry

Texel. "Contrast Adaptive Sharpening." https://texelatlas.vercel.app/t/contrast-adaptive-sharpening/ (accessed 2026-12-01).
