Baltor Get started

Gallery / Godot shaders

Smooth nearest sampling for scaled pixel art

In your harnessGodot shaderMIT

Keep pixel art crisp but free of shimmering when it is rotated, moved by sub-pixels or scaled by non-integer factors: texel edges are blended over exactly one screen pixel with linear filtering, interiors stay flat.

Render of Smooth nearest sampling for scaled pixel art
The render its check recorded in Godot 4.7.2, 256 by 256 pixels.

What it takes and gives

Shader type
canvas_item
Parameters
edge_sharpness (float = 1), enabled (bool = yes)
Use it on
A pixel art texture on a Sprite2D whose texture_filter is set to Linear (as in demo.tscn).
Result
A 24-pixel sprite scaled seven times with crisp, flat texels and smooth edges.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/sprite_pixel_art_aa/

Limits. Requires the node's texture filter set to Linear; with Nearest filtering it has no effect. Mipmaps must be off or the blend smears when minified.

Details

Kind
Godot shader
Engine
Godot 4.3 or later
Files
11 files, 61.4 KB
Licence
MIT
Declared effects
reads files, runs commands
Checked with
Godot 4.7.2, opengl3 compatibility (Mesa llvmpipe, Xvfb)
Checks
contract static, engine run, engine log clean, shader in scene, capture written, render not uniform, shader changes pixels
Techniques
Anti-aliased nearest-neighbour sampling (bilinear blend confined to one screen pixel at texel edges), Screen-space derivatives of texel coordinates
Tags
godot shader, canvas item, pixel art, anti-aliasing, scaling, rotation, 2d
Identity
library.supply.creative_originals.2310a8837a972802fae57c64.37ae350f0f6a17f7
Version
37ae350f0f6a17f7a4cd2a71c052ed850c3349f32a0b5d7ac09ec34df2962038

The version is the SHA-256 of the item your harness downloads; every file in it names its own checksum.

Something wrong with this item, its rights or its safety? Report it on the support page, or from your harness after a download.