Compare 8bit pipet float to 32bit float

hi all,

I have a skia canvas with multiple objects, and render the same scene a second time for hitdetection with a pipet. the idea is that my object ID correlates with the texture brightness.
Each object is on a separate zLayer.

sk2 sk1

Using a 256 linear spread for IDs does not work, because the 8bit precision from the texture readback produces rounding errors. What IDs (=colors) can I use for the objects, that can be represented perfectly as colors? I would like to avoid splitting the ID into multiple channels.

texture8bitRounding.vl (10.5 KB)

Maybe saving as bits or hex is an option?

probably you can get away with a very low epsilon?
haven’t peeked inside, but maybe check how it got solved here, it’s basically doing the same in beta:

1 Like

HEX

thx!

you can use a Repeat loop to generate the exact colors. and you have 3 color channels, so there is even more info you could pack in there…
image

yes, the good old shader trick for floatpacking :)
thx!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.