Contrast Adaptive Sharpening
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.
Also known as CAS
In the family Post-processing, color & imaging, sharpening
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { sharpen } from 'three/addons/tsl/display/SharpenNode.js' docs Implements RCAS, the FidelityFX CAS derivative. |
| Babylon.js 9.38.0 | None found | DefaultRenderingPipeline.sharpenEnabled uses a 3x3 convolution kernel (SharpenPostProcess), not AMD FidelityFX CAS. |
| Godot 4.7 | Built in | Viewport.scaling_3d_mode = SCALING_3D_MODE_FSR (FSR 1.0 RCAS sharpening via fsr_sharpness) docs |
| Unity | Built in | HDRP Asset > Dynamic Resolution > Upscale Filter = Contrast Adaptive Sharpen (CAS) docs HDRP only, as a dynamic-resolution upscale filter. |
| Unreal 5.7 | Built in | Temporal Super Resolution (TSR) and r.Tonemapper.Sharpen post-upscaling sharpening docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
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 or NVIDIA DLSS when those already apply one, to avoid double sharpening. Prefer no sharpening for stylized flat-shaded content.
Field marks
- 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
Presets
Left: softened image. Right: CAS, a 5-tap cross whose strength is scaled by local min/max contrast
{
"SHARP": 1
}Show GLSL (29 lines)
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
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| contrast-adaptive-sharpening-specimen | Tesla T4 1920x1080 | 14.6× baseline (moderate) · 0.480 ms / 0.492 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| contrast-adaptive-sharpening-specimen | NVIDIA L4 1920x1080 | 11.2× baseline (moderate) · 0.178 ms / 0.180 ms · 2.7× faster on L4 | opengl-timer-query · Cross-architecture validation |
| contrast-adaptive-sharpening-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 9.21× baseline (moderate) · 0.265 ms / 0.266 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Temporal Anti-Aliasing: Run after the TAA resolve to counter its blur.
Sources
- primaryGPUOpen-Effects (2020). GPUOpen-Effects/FidelityFX-CAS. Contrast Adaptive Sharpening (CAS)GitHub API · license MIT · 2026-11-29
- tutorialAMD GPUOpen. FidelityFX Contrast Adaptive Sharpening. gpuopen.com.Verified via live page · 2026-11-29