how the pixel match comparison works
A simple, non-technical overview of how the compute shader compares shadow pixels.
Last updated
A simple, non-technical overview of how the compute shader compares shadow pixels.
You have two “shadow pictures”:
Source — the player’s current shadow (what they’re casting).
Target — the correct shadow for the puzzle (the answer).
The compute shader compares them pixel by pixel on the GPU.
For each pixel position, the shader looks at how visible the shadow is (the alpha: 0 = no shadow, 1 = full shadow).
A pixel is only included if at least one of the two images has some shadow there (so we only grade “shadow” pixels, not empty background).
For those pixels, it checks: is the shadow strength in the source almost the same as in the target?
“Almost” is controlled by a small tolerance (about 5% difference). So tiny differences (soft edges, antialiasing) still count as a match; only clearly wrong darkness counts as a miss.
The shader counts:
Matching pixels — pixels where the source shadow strength is close enough to the target.
Total pixels — all pixels that had shadow in either image.
The game then does: match % = (matching pixels ÷ total pixels) × 100.
The GPU runs many small “workers” in parallel, each checking a few pixels, then they combine their counts. So we can compare a full screen of pixels very quickly instead of doing it one-by-one on the CPU.
Last updated