Skip to content

Commit b304ea8

Browse files
author
Christopher Willis-Ford
committed
Make touching-color test more robust against GPU imprecision
Previously, the `color-touching-tests.sb2` test "touches a color that doesn't actually exist right now" would use a sprite with ghost 50, blended against another sprite, to create the color that "doesn't actually exist" when the query sprite is skipped. Unfortunately the blend result was near a bit-boundary and, depending on the specific hardware used, that test could fail on the GPU. When the renderer uses the CPU path this test works fine, though, so the existing problem went unnoticed. To fix the problem I changed the project to use ghost 30 instead, which results in a color that is less near a bit boundary and is therefore less likely to fail on specific hardware. As an example of what was happening: the `touching color` block was checking for `RGB(127,101,216)` with a mask of `RGB(0xF8,0xF8,0xF0)`. On the CPU it would find `RGB(120,99,215)`, which is in range, but on some GPUs the closest color it could find was `RGB(119,98,215)` which mismatches on all four of the least significant bits -- one of which is enabled in the mask.
1 parent f9428ee commit b304ea8

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

src/RenderWebGL.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ class RenderWebGL extends EventEmitter {
777777
debugCanvasContext.fillRect(x, y, 1, 1);
778778
}
779779
// ...and the target color is drawn at this pixel
780-
if (colorMatches(color, color3b, 0)) {
780+
if (colorMatches(color3b, color, 0)) {
781781
return true;
782782
}
783783
}
Binary file not shown.

0 commit comments

Comments
 (0)