var decodeDepth; var rEncode = color.r; var gEncode = color.g; var bEncode = color.b; // This loop decodes depth into a 24 bit value split across all three color channels. // The least significant digit is the last blue value. // The most significant digit is the first red value. for (var i = 0; i < 8; i++){ decodeDepth |= ((bEncode) & 1) << i; decodeDepth >>= 1; decodeDepth |= ((gEncode) & 1) << i; decodeDepth >>= 1; decodeDepth |= ((rEncode) & 1) << i; decodeDepth >>= 1; }