Skip to content

Variable: PICK_ENCODE_GLSL ​

ts
const PICK_ENCODE_GLSL: '\nvec4 holochartEncodePickId(uint id) {\n  uint v = id + 1u;\n  vec4 bytes = vec4(float(v >> 24u), float((v >> 16u) & 255u), float((v >> 8u) & 255u), float(v & 255u));\n  return min((bytes + 0.25) / 255.0, vec4(1.0));\n}\n';

Experimental

vec4 holochartEncodePickId(uint id): the RGBA8 encoding of id + 1 (0 = background), with the same +0.25 byte bias as encodePickId so truncating and rounding float → unorm conversions both return the intended byte.

Released under the MIT License.