Smooth Corners 3.0: Technical Perspective

August 26

Technical Goals

Smooth corners are a fundamental rendering primitive in a system UI. They appear in buttons, cards, masks, icon containers, panel corners, and many other places, with radii potentially ranging from 0.5px0.5 px to 1000px1000 px.

The technical solution therefore needs to meet four requirements at once:

  • Stable shapes, without noticeable distortion when scaled
  • Smooth edges, without visible jaggedness in high-contrast conditions
  • Manageable runtime cost, without repeating expensive calculations for every corner in the system
  • Broad applicability, supporting long-term evolution from 2D UI to more complex real-time rendering scenarios

Technical Architecture

Rendering pipeline

The pipeline can be summarized in four steps:

  1. Define the ideal corner shape using a curve with high-order continuity.
  2. Rasterize the vector curve into a cached texture using high-quality anti-aliasing.
  3. Generate multiple mipmap levels from the cached image for stable rendering at different scales.
  4. Filter and sample the texture on the GPU at the appropriate level of detail (LOD), then output it to the screen.

The key is to move as much expensive, high-quality work as possible into offline processing or precomputation, leaving runtime work to the sampling operations GPUs handle best.

Curve Modeling: Why Degree-4 NURBS?

NURBS (non-uniform rational B-spline) curves offer a high degree of control, including fairly direct control over local curvature changes. In this project, curve modeling needed to satisfy two requirements:

  • Achieve G4 geometric continuity: the corner is both a visual element and a geometric foundation that may feed into lighting, normal generation, and other rendering stages. Higher continuity leaves more room for future uses.
  • Stay as close as possible to a circular arc: many existing system elements are already visually associated with circular corners, so an upgrade should not abruptly change the platform's character.

Illustration of G4 continuity

Comparison with circular corners

A superellipse is a natural candidate if mathematical smoothness is the only concern. But in system design, curves do not exist in isolation. The negative space formed by adjacent corners also affects how users perceive the platform's character. The final technical choice was therefore an engineering decision constrained by the design language.

Rasterization: Why SSAA?

Modern screens are pixel arrays, so vector curves ultimately have to be converted into pixels. There is no shortage of rasterization approaches. The real question is which approach is worth precomputing and caching once the corner shape has been fixed.

TechniqueOverviewAdvantagesDisadvantages
SSAA (supersample anti-aliasing)Render at a higher resolution, then downsample for smoother edgesHighest image quality, almost no jagged edges, broadly applicableHigh processing and memory costs
MSAA (multisample anti-aliasing)Take multiple samples at geometric boundaries to improve edge smoothnessBalances performance and quality; effective on geometric edgesLimited support for transparent textures and complex pixel effects
FXAA (fast approximate anti-aliasing)Detect and blur edges in a pixel-shader post-processing passVery low cost, easy to integrateLost detail, blurred edges, limited results in high-contrast scenes
TAA (temporal anti-aliasing)Sample and blend data from previous frames to reduce aliasingEffective aliasing reduction; useful in dynamic scenesCan introduce trails and ghosting, compromising results in motion
CMAA (conservative morphological anti-aliasing)Combine edge detection and blending to balance performance and qualityLow cost, broad compatibilityLimited effectiveness; visible aliasing can remain in some scenes

Anti-aliasing comparison

Because the corner shape is a cacheable system asset rather than complex geometry that changes every frame, we can choose SSAA for its image quality, rasterize once, and reuse the result. Moving this expensive, high-quality work into the caching stage substantially reduces its runtime burden.

Resampling: Why Lanczos and Nine Mipmap Levels?

A single high-resolution corner image does not solve every problem. Relying on a single 512px×512px512 px \times 512 px cached image for large reductions at runtime produces visible aliasing because the sampling frequency no longer matches the image content.

This is why I approached it as a conventional texture-pipeline problem:

  • Create a high-quality master image.
  • Generate multiple mipmap levels.
  • Sample at runtime from a level with a more suitable frequency range.

The following resampling algorithms were considered:

Algorithm / TypeMethodAdvantagesDisadvantages / Notes
Nearest neighborTake the pixel at the nearest integer coordinates, without interpolationHardware-supported; extremely fast and simpleVisible blocks and jagged edges; lowest quality
BilinearLinearly interpolate a weighted average of the surrounding 2x2 pixelsHardware-supported; smooth and fastBlurred edges and lost detail
BicubicInterpolate a 4x4 neighborhood using a cubic convolution kernelBalances sharpness and smoothness, with good detailMore computation; possible mild ringing
Lanczos resampling (windowed sinc)Interpolate a larger neighborhood, such as 6x6, using a windowed sinc kernelSharp results and excellent aliasing suppressionHigh cost; possible ringing
Mitchell–NetravaliUse an adjustable cubic kernel, commonly used for high-quality scalingBalances detail and smoothness; suitable for content pipelinesModerate algorithmic complexity
Area / BoxAverage the input region covered by each output pixel, typically for downscalingFast, with good anti-aliasing when downscalingBlurring and detail loss when upscaling
GaussianBlur with Gaussian weights, then sampleNatural smoothness and good aliasing suppressionLost detail and relatively high computational cost
Catmull–RomUse a sharp cubic interpolation kernel, commonly used in content pipelinesClear edges and good detailRisk of ringing; moderate cost

Resampling comparison

Lanczos was chosen for two reasons:

  1. It suppresses aliasing well enough to produce cleaner edges when downscaling.
  2. It preserves the original signal's shape more faithfully, rather than softening away the intended curvature relationships.

Using a window parameter of a=3a = 3, we can convolve the original image L0L_0 with a normalized discrete Lanczos kernel to obtain the first resampled image L1L_1: (I∗La)[i,j]=∑m=i−a+1i+a−1∑n=j−a+1j+a−1I[m,n]  La(i−m)  La(j−n)(I * L_a)[i,j] = \sum_{m=i-a+1}^{i+a-1} \sum_{n=j-a+1}^{j+a-1} I[m,n]\; L_a(i - m)\; L_a(j - n)

Repeating the operation recursively on L1L_1 produces the remaining mipmap levels: Ln=I∗Ln−1L_{n} = I * L_{n-1}

Multiple mipmap levels are necessary rather than directly reducing a single image. Otherwise, large scale reductions are more likely to produce moiré patterns.

Mipmap aliasing comparison

Image source: Wikimedia Commons.

The on-device photographs below compare nearest-neighbor, linear, Mitchell, and Lanczos resampling. Nearest-neighbor and linear resampling show visible jaggedness. Mitchell and Lanczos are both sufficiently smooth, but further magnification shows that Lanczos better preserves the original curve's shape.

On-device resampling comparison 1

On-device resampling comparison 2

Runtime Sampling: Why Trilinear Filtering Is Enough

The final stage samples and filters the texture across the mipmap chain. Common options include:

Filtering MethodOverviewAdvantagesDisadvantages
Nearest neighborUse the color of the nearest pixelSimple and fastVisible aliasing and lost detail
Nearest neighbor with mipmappingCombine nearest-neighbor sampling with multiple mipmap levelsFast; reduces artifacts at a distanceAliasing remains; abrupt transitions
BilinearLinearly interpolate the four pixels surrounding the sample pointSmooth edges and good performanceBlurred detail; artifacts can remain at a distance
Trilinear with mipmappingLinearly interpolate between mipmap levels, using bilinear filtering within each levelSmooth transitions, with reduced aliasing and artifactsHigher cost; detail remains limited
AnisotropicAdapt sampling to the viewing angle to improve texture clarity at oblique angles and at a distanceStrong detail preservation; best results at oblique angles and at a distanceHigher cost and greater hardware requirements

The primary target is mobile UI, not textures viewed at steep perspective angles, so anisotropic filtering offers little benefit for its cost. Trilinear filtering with mipmapping is a cost-effective final stage: image quality is already stable enough, and modern GPUs provide mature hardware support.

Final rendering result

Results in Practice

Examining the display's subpixels under a microscope makes the improvement clear: the new corners transition more smoothly from straight edges into curves, largely eliminating the bump visible in the previous version.

NEW (OS3)
OLD (OS2)

Future Evolution

After more than three years of intermittent research and analysis of other industry implementations, high-performance smooth corners can now be described through a relatively stable technical architecture. If a better algorithm becomes available for an intermediate graphics stage, that stage can be replaced without rebuilding the entire pipeline.

For resampling, for example, convolution kernels such as John Costella's Magic Kernel may offer potential value on certain low-resolution devices. For me, the most important result is not the particular algorithm chosen for this release, but turning the rounded-corner problem into a graphics pipeline that can keep evolving.