A dip that was the test, not the game
The match against the browser game came out at 57.988% across 78 shots, 1.6 points below the last full measurement of 59.619% on 6 September. All of the drop was in the walking and running shots, which fell from 72.4% to 59.6%. The cause was not the drawing.
Walk speed had been raised on 13 and 14 September, from the browser's 40 up to 68 and then 88, because the game felt slow. The comparison shots hold a key down for a fixed number of frames, so at the faster speed the player covers more than twice as much road as the browser does, and the pictures can no longer line up. The comparison now runs those shots at the browser's speed of 40 while the game itself still walks at 88. The motion shots score 72.4% again and the overall match is 59.629% across all 78 shots. A score cannot say whether the walk animation looks right at the faster speed. That needs someone playing it.
Night lighting
With about a hundred lights in view, one frame took around 180 ms, roughly five frames a second. The old code worked out the same brightness rounding again for every pixel a light touches. It now works it out once per light, and each pixel looks up the answer.
| scene | before | after |
|---|---|---|
| town at 22:00 in rain | 155 ms | 84 ms |
| town at 23:00 in fog | 186 ms | 114 ms |
| town at 21:00, autumn | 104 ms | 53 ms |
| town at 23:30 | 64 ms | 44 ms |
Full frame time on a headless renderer, taken on a busy machine, so read it as relative.
Fog and wet streets
Weather was next: about 30 ms at dawn and 51 ms in night fog, against 8 ms in clear weather. Most of it was the sixteen large soft fog images. The drawing code worked out, for every pixel, which pixel of the image to read, through a full matrix calculation, when a plain whole-pixel stretch needs that answer once per column and once per row. It now does exactly that and skips transparent pixels, taking the weather part of a frame in night fog from about 56 ms to 36 to 45 ms.
Wet streets cost 26 to 36 ms of a frame in rain and fog, for two reasons. The darkening and the road sheen each cut the same building-free outline out of the screen separately, so it is now cut once and shared. And the big darkening fill used floating-point maths on every pixel, when for a solid pixel each colour channel's result depends only on that channel's old value, so it now uses three small lookup tables built with the very same function.
| weather cost per frame | before | after |
|---|---|---|
| rain | 26 ms | 16 ms |
| overcast | 23 ms | 12 ms |
| fog | 30 ms | 20 ms |
| storm | 38 ms | 29 ms |
How it was checked
Nothing looks different. Fourteen test frames (fog, rain, a storm, the ruined town, an interior, the title and pause screens) are byte for byte identical before and after, the 78-shot match stays at 59.629%, and the Unity compile, all 931 editor tests and both play-mode tests pass.
