What a machine computes

A display's scales cancel, if they are true maps

Between a renderer's buffer and a screenshot there may be two more resamples: a compositor reducing a whole-number scale to the panel, and a screenshot read back at the window's size. Each rounds to whole pixels, and under the true map the roundings telescope: only the last size and the renderer's assumed aspect matter, so the one-rounding bound survives, and a screenshot at the window's size shows the square camera exactly. A naive step breaks the bound in six per cent of windows and moves every centre.

Worth reading first: A pixel is not a point · Four numbers and a window.

A rounded viewport has two focal lengths found a fault in the most ordinary line of a renderer. The aspect ratio is computed from the window’s requested size, the picture is drawn into a buffer of whole device pixels, and on a display whose scale is not a whole number the buffer’s width and height round differently. The camera then has two focal lengths, differing by up to one part in three hundred. At the frame’s edge that is a bounded displacement, never more than a quarter of a pixel times one plus the buffer’s aspect, on any window at all, and the cure is one line: take the aspect from the buffer.

The essay noted that the buffer is not the end of the road. On a fractional display a compositor often draws a window at a whole-number scale and reduces it to the panel’s pixels, which is a resample with a filter; and a screenshot of the panel may itself be read at the panel’s size or at the window’s logical size. If those steps use the true map between pixel grids, halving a picture moves its centre has already said what each one does. If they use another, there is another centre in play. The question left was whether the composition can exceed the bound the single rounding set, and whether a screenshot of a rendered scene still shows the camera the renderer thought it was using.

Three steps between the camera and the screenshot

The renderer’s camera is the earlier essay’s: a vertical field of 60°, an aspect ratio taken from the window’s requested width and height, and a buffer of whole pixels. From there, each pipeline is a list of sizes and a map between each pair. The true map sends pixel xx on a grid of nn to s(x+12)−12s(x + \tfrac12) - \tfrac12 on a grid of mm, with s=m/ns = m/n, so the centre of the first grid lands on the centre of the second. The naive map sends it to s xs\,x, which pins the corner of the first pixel instead, and moves the centre by (1−s)/2(1 - s)/2 of the new grid’s pixels.

Six pipelines are compared. Drawing directly into a fractional buffer and reading it at the panel’s size is the earlier essay’s case. The same buffer read back at the window’s logical size adds one true-map step. A composited window is drawn at the next whole number of the device scale, twice its logical size at a scale of 1.5, and reduced to the panel by the true map; that can then be read at the panel’s size, or read back at the logical size. Two pipelines use the naive map, for the compositor alone and throughout. The error measured is the displacement at the frame’s edge, in the screenshot’s own pixels, between where the screenshot puts a mark and where a square camera centred on the screenshot would.

Through a display's own scales the error stays bounded, unless a step uses the naive mapThe largest displacement at the frame's edge between a screenshot and a square camera centred on it, in the screenshot's pixels, over 9,630 windows from 320 to 2,560 px wide in six shapes at device scales of 1.25, 1.5, 1.75, 2.25 and 2.5. direct: 0.708 px; direct, logical shot: 0.000 px; composited: 0.708 px; composited, naive: 0.915 px, past the one-rounding bound in 586; composited, logical shot: 0.000 px; naive throughout, logical shot: 0.471 px, past the one-rounding bound in 642. A screenshot taken at the window's logical size shows no anisotropy at all when every step is the true map.direct0.708 pxdirect, logical shot0.000 pxcomposited0.708 pxcomposited, naive0.915 pxcomposited, logical shot0.000 pxnaive throughout, logical shot0.471 pxworst over every windowpale: breaks the bound
Fig. 1 The largest displacement at the frame’s edge, in the screenshot’s pixels, over 9,630 windows from 320 to 2,560 px wide in six shapes at device scales of 1.25, 1.5, 1.75, 2.25 and 2.5, for six pipelines. Pale bars mark pipelines that break the one-rounding bound in some window.

The direct pipeline and the composited one have the same worst case, 0.708 px, in the same window, and neither breaks the one-rounding bound anywhere. Both pipelines that read the screenshot back at the window’s logical size show nothing: a displacement of zero to the precision of the arithmetic, in every window. The naive compositor reaches 0.915 px and breaks the bound in 586 of the 9,630 windows; the naive chain to a logical screenshot breaks it in 642.

The roundings telescope

That the composited pipeline matches the direct one exactly is not a coincidence of the windows chosen. It follows from what the true map does to a camera.

A true-map step scales the camera’s horizontal focal length by the step’s horizontal scale, mx/nxm_x/n_x, and its vertical by my/nym_y/n_y, and keeps the centre at the centre. Carried through any number of steps, the horizontal focal length is the first buffer’s times the product of the horizontal scales, and that product telescopes to the last width over the first; likewise vertically. The renderer set its horizontal focal length to the first buffer’s width over twice the assumed aspect times the tangent of the half-field, and its vertical to the first buffer’s height over twice the tangent. So at the end,

fxfy=wlast/hlasta,\frac{f_x}{f_y} = \frac{w_\text{last}/h_\text{last}}{a},

the final picture’s aspect over the aspect the renderer assumed. Every size in between has cancelled. A compositor that draws at twice the window’s size and reduces to the panel produces exactly the camera the direct pipeline produced, since both end at the panel’s size, and nothing the compositor rounded on the way survives.

A rounding the panel adds, the screenshot at the window's size takes awayA 1279×719 window at a device scale of 1.5, drawn at twice its size, reduced to the panel and read back at its own size, every step by the true map. Drawn at 2558×1438 the camera is exactly square. Reduced to 1919×1079, a size that rounds the width and the height differently, its two focal lengths differ by 203 parts per million and the frame's edge is 0.195 px out. Read back at 1279×719, the difference is 0 and the edge 0.000 px: the last scale undoes the rounding of the one before.render, 2558×1438: fx/fy − 1, ppm0edge displacement, thousandths of a px0panel, 1919×1079: fx/fy − 1, ppm203edge displacement, thousandths of a px195screenshot, 1279×719: fx/fy − 1, ppm0edge displacement, thousandths of a px01279×719 at 1.5true maps throughout
Fig. 2 A 1279×719 window at a device scale of 1.5, drawn at twice its size, reduced to the panel and read back at its own size, every step by the true map: the camera’s anisotropy in parts per million and the frame’s edge displacement in thousandths of a pixel, at each step.

The window shown makes it concrete. Drawn at 2558×1438, twice its logical size, its camera is exactly square, because the buffer is a whole-number multiple of the requested size and the aspect it assumed is the buffer’s own. Reduced to the panel’s 1919×1079, which rounds 1918.5 up and 1078.5 up, it acquires two focal lengths that differ by 203 parts per million, and its frame’s edge is 0.195 px out. Read back at 1279×719, the window’s own size, the difference is gone: zero parts per million and zero displacement. The last scale undid the rounding of the one before, because it rounded back to the sizes the renderer’s aspect was taken from.

A screenshot at the window’s size shows the renderer’s camera

That answers the second half of the question directly. A screenshot read back at the window’s logical size has, by the formula, an aspect equal to the window’s, which is the aspect the renderer assumed. Its camera is therefore exactly square and exactly centred, whatever the device scale, whatever the compositor did between, provided every step used the true map. The fault the earlier essay found in the buffer is real at the panel and absent at the logical size, and a person recovering the camera from such a screenshot, with recovering the camera or with the box-and-square reading a box leaves a line of cameras set out, finds the camera the renderer meant.

A screenshot read at the panel’s size shows the panel’s camera, which has the anisotropy of the panel’s rounding and no more. That is also bounded by the single rounding’s bound, in the panel’s pixels. The composition cannot exceed the bound, because in true maps the composition is the last rounding alone.

A window being dragged

The worst case over thousands of windows hides the shape of the error for any one of them. A window being resized a pixel at a time shows it.

A window dragged from 1,200 to 1,260 px wide at a device scale of 1.5The displacement at the frame's edge, in the screenshot's pixels, as a 16:9 window is widened a pixel at a time at a device scale of 1.5. Drawing straight into a fractional buffer, or at a whole-number scale and reducing it by the true map, gives the same saw-tooth (solid), at most 0.444 px against a bound near 0.69 (dotted line). Reducing by the naive map adds the centre's own offset on top (dotted curve), up to 0.583 px. A screenshot at the window's logical size (dashed) shows 0.000 px. The slider changes the device scale.00.2500.5000.75011.2e+31.22e+31.24e+31.26e+3window width (CSS px), 16:9edge displacement (screen px)direct or compositedcomposited, naive maplogical-size screenshotdevice scale 1.5naive: 0.58 px
Fig. 3 The displacement at the frame’s edge, in the screenshot’s pixels, as a 16:9 window is widened from 1,200 to 1,260 CSS px a pixel at a time, for drawing directly or composited by the true map (solid), composited by the naive map (dotted), and read back at the logical size (dashed), with the one-rounding bound for comparison. The slider changes the device scale.

At a device scale of 1.5 the direct and composited pipelines draw the same saw-tooth, rising to 0.444 px and falling back to nothing whenever the width and height round alike; the bound is near 0.69. The naive compositor adds its centre’s offset on top, a constant 0.125 px at this scale in each direction, and its curve rides above the saw-tooth to 0.583 px. The logical-size screenshot stays flat at zero. Dragging the slider changes the device scale: at 1.25 the saw-tooth’s teeth are wider and the naive offset larger, 0.188 px; at 1.75 the offset is 0.063 px; at 2.5, with a whole-number scale of 3 behind it, it is 0.083.

A naive step moves every centre

The naive map does something the true map never does, which is to move the picture’s centre, and the amount has a simple form.

A naive chain leaves the centre by one minus its whole scale, over twoHow far the picture's centre lands from the frame's centre, in the screenshot's pixels, for a 1280×720 window drawn at the next whole-number scale and reduced by the naive map. At the panel's size (solid) the offset is (1 − s)/2 for the reduction's scale s: 0.188 at 1.25, 0.125 at 1.5, 0.063 at 1.75, 0.000 at 2, 0.125 at 2.25, 0.083 at 2.5, 0.042 at 2.75, 0.000 at 3, and nothing at whole-number scales. Read back at the window's size by another naive step (dashed) it is (1 − 1/k)/2 for the whole-number scale k, 0.250 px for every scale up to 2 and 0.333 up to 3, whatever the panel's scale was in between.00.1000.2000.3000.4001.5022.503the display's device scalecentre offset (screen px)panel-size screenshotlogical-size screenshot1280 × 720, naive mapsthe centre, not the focal lengths
Fig. 4 How far the picture’s centre lands from the frame’s centre, in the screenshot’s pixels, for a 1280×720 window drawn at the next whole-number scale and reduced by the naive map, read at the panel’s size (solid) and read back at the window’s size by a second naive step (dashed), against the device scale.

At the panel’s size the offset is (1−s)/2(1 - s)/2 for the reduction’s scale ss, the panel’s scale over the whole-number one: 0.188 px at 1.25, 0.125 at 1.5, 0.063 at 1.75, nothing at 2 and 3, where there is no reduction. The naive maps compose like the true ones, as a single naive map with the product of the scales, so a second naive step to the window’s logical size leaves the centre at (1−1/k)/2(1 - 1/k)/2 for the whole-number scale kk: a quarter of a pixel for every device scale up to 2, and a third of a pixel up to 3, whatever the panel’s scale was in between. The panel’s scale has cancelled and the whole-number scale has not.

That is the earlier essay’s quarter of a pixel, from halving a picture with the naive map, appearing in a new place. A screenshot of a window on a display at 1.5 read back at its logical size, if every step pinned corners rather than centres, shows its camera’s centre a quarter of a pixel up and to the left of the frame’s centre, and a third of a pixel on a display at 2.5. It is the only error left in that screenshot, and it is a displacement at every point of the frame, not a growing one, so it shows at the frame’s edge as a constant 0.35 px for k=2k = 2, past the bound for every window of that shape.

How the windows spread

The worst case says what can happen. The distribution says what usually does.

Most windows are well inside the bound, and a naive step moves all of themThe share of the windows swept whose frame edge is displaced by more than the amount on the horizontal axis. Drawn straight into a fractional buffer (solid), half are under 0.150 px and 7.1% are past half a pixel. Reduced from a whole-number scale by the naive map (dotted), 16.4% are past half a pixel. Naive throughout and read at the window's size (dashed), 100% are past a quarter.025507510000.2000.4000.6000.8001edge displacement (screen px)windows past it (%)directcomposited, naivenaive throughout, logical shot9,630 windowsfive fractional scales
Fig. 5 The share of the 9,630 windows whose frame edge is displaced by more than the amount on the horizontal axis, for drawing directly into a fractional buffer (solid), composited by the naive map (dotted), and naive throughout to a logical screenshot (dashed).

Drawing directly, half of the windows are displaced by less than 0.15 px at the edge, and 7.1 per cent by more than half a pixel. The naive compositor moves the whole distribution up by its centre offset: 16.4 per cent of windows are past half a pixel. Naive throughout and read at the window’s size, every window is past a quarter of a pixel, since the centre’s offset is there in all of them, and the anisotropy is gone in all of them, so the distribution is a step.

The two kinds of error are worth separating because they are found differently. An anisotropy grows from the centre outward, and a recovery that reads the camera’s focal lengths separately sees it as two focal lengths; the pixel that is not square measured how small a difference such a recovery can see. A centre offset is the same at every point, and a recovery sees it as a principal point off the middle of the frame, which most recoveries assume rather than read. So the naive chain’s quarter of a pixel is the one a reader is least likely to find, and the true chain’s anisotropy, which a logical screenshot removes, is the one a reader is most likely to look for.

What a reading of a screenshot should assume

The results turn into three rules for anyone measuring a rendered scene from a screenshot of it. Take the screenshot at the window’s logical size if the renderer computed its aspect from the window’s requested size, which is the common case, because that is the one picture in the chain whose camera is the renderer’s own. Take it at the panel’s size if the renderer computed its aspect from its buffer, for the same reason with the roles reversed. And treat the principal point as unknown to a third of a pixel, unless every step that touched the picture is known to have used the true map, since the naive map’s offset is the one error no amount of care with the sizes removes.

The first two rules cost nothing and remove the anisotropy entirely. The third is a matter of which numbers a recovery fixes and which it reads. A square closes the line of cameras found a single square in the scene enough to fix a camera’s two focal lengths and its centre together, and a recovery that reads the centre in that way finds the naive chain’s quarter of a pixel; one that assumes the centre is at the middle of the frame inherits it as a small turn of the camera, about a fiftieth of a degree at these focal lengths, which no other reading of the picture will contradict.

Where the true map comes from

Every graphics interface that samples a texture by pixel centres, which is all of them since the convention settled, resamples by the true map when it draws one image into another of a different size with matched corners. The naive map appears in code that scales coordinates instead of images: an event handler that converts a mouse position by multiplying by the scale, a screenshot routine that multiplies a stored rectangle by the device scale, a layout engine that positions a child by scaling its parent’s offsets. Each of those is a place where a pixel index is multiplied by a ratio without the half-pixel on either side, which is what a pixel is not a point found the half-pixel convention exists to prevent.

So the practical conclusion depends on which part of a pipeline is in question. The pixels a compositor moves are almost always moved by the true map, and the measurement says they are then harmless: they cannot add to the renderer’s own rounding, and read back at the window’s size they remove it. The coordinates a program computes about those pixels, such as where a mark is, where a click landed, or where to crop, are where the naive map lives, and a quarter of a pixel there is a quarter of a pixel in every measurement made from the picture.

Filters, and what was assumed about them

A real compositor’s reduction is not only a map but a filter, bilinear or a wider kernel, and a filter blurs. A symmetric filter moves no centroid, so a mark’s position, read as the centroid of its blur, is where the map put it; that is why the map alone decides the geometry here. A filter that is not symmetric about its sample, as some fast reductions are, adds its own fixed offset in the same way the naive map does. The renderer’s camera is a pinhole with a vertical field of 60° and its aspect taken from the window’s requested size; a renderer that takes its aspect from the buffer, as the earlier essay’s cure recommends, gets a square camera at the panel and an anisotropic one in a logical screenshot, by the same formula with the roles reversed.

The windows swept are the earlier essay’s: widths from 320 to 2,560 CSS px in steps of 7, in six shapes from 9:16 to 21:9, at five fractional device scales. The whole-number scale a compositor draws at is the next whole number above the device scale, which is the common choice; a compositor that draws at the device scale rounded to the nearest whole number would reduce some windows and enlarge others, and the telescoping argument covers it unchanged.

Still open: whether a crop keeps the camera

Every pipeline here carries the whole frame. A screenshot of part of the screen, a crop around a window or a region, has its own frame, and a crop does not scale anything: it moves the frame’s centre and leaves the camera’s centre where it was. A crop whose edges fall on whole pixels moves the centre by a whole or half number of pixels; a crop computed in logical coordinates and converted by the naive map lands its edges on fractional pixels and rounds them.

The measurement that settles what that adds crops the composited screenshot by rectangles specified in logical coordinates, converted by each map and rounded, and asks how far the cropped picture’s principal point lands from where the renderer’s camera puts it; whether the error is a bounded fraction of a pixel, like the roundings here, or depends on where on the screen the crop was taken; and whether a recovery that reads the principal point from a cropped screenshot can tell a crop’s offset from a camera’s, which a tile is an off-centre frustum found a renderer deliberately creates when it draws one picture in pieces.

A crop moves the frame and not the camera makes that measurement.

True-map resamples telescope: a camera carried through a compositor’s reduction and a screenshot’s readback has the final picture’s aspect over the renderer’s assumed one, and nothing in between survives. So the one-rounding bound holds through any display, and a screenshot at the window’s size shows the renderer’s square camera exactly. A naive step moves every centre by one minus its scale, over two, and that is what breaks the bound.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

AnisotropyAspect ratioFocal lengthPrincipal pointQuantisationSampling grid