qr shader: add version information for size 7+

This commit is contained in:
Crispy 2024-08-18 18:30:25 +02:00
parent 7e4d06169c
commit 5f839b88ae

View file

@ -52,6 +52,9 @@ CGPROGRAM
#define FORMAT_BITS_RAW ((EC_LEVEL << 3) | MASK_TYPE) #define FORMAT_BITS_RAW ((EC_LEVEL << 3) | MASK_TYPE)
#define FORMAT_BITS FORMAT_BIT_SETS[FORMAT_BITS_RAW] #define FORMAT_BITS FORMAT_BIT_SETS[FORMAT_BITS_RAW]
static const uint VERSION_BIT_SETS[34] = {0x07C94,0x085BC,0x09A99,0x0A4D3,0x0BBF6,0x0C762,0x0D847,0x0E60D,0x0F928,0x10B78,0x1145D,0x12A17,0x13532,0x149A6,0x15683,0x168C9,0x177EC,0x18EC4,0x191E1,0x1AFAB,0x1B08E,0x1CC1A,0x1D33F,0x1ED75,0x1F250,0x209D5,0x216F0,0x228BA,0x2379F,0x24B0B,0x2542E,0x26A64,0x27541,0x28C69};
#define VERSION_BITS (VERSION > 6 ? VERSION_BIT_SETS[VERSION - 7] : 0)
#define WHITE 1 #define WHITE 1
#define BLACK 0 #define BLACK 0
#define PINK float3(1, .3, .5) #define PINK float3(1, .3, .5)
@ -121,6 +124,18 @@ CGPROGRAM
// bottom // bottom
if (px == 8 && py > WIDTH - 8) return (FORMAT_BITS & (1 << py + 15 - WIDTH)) == 0; if (px == 8 && py > WIDTH - 8) return (FORMAT_BITS & (1 << py + 15 - WIDTH)) == 0;
// version information
if (VERSION > 6) {
if (px < 6 && py > WIDTH - 12) {
uint b = px * 3 + py - (WIDTH - 11) ;
return ((VERSION_BITS >> b) & 1) == 0;
}
if (px > WIDTH - 12 && py < 6) {
uint b = px - (WIDTH - 11) + py * 3;
return ((VERSION_BITS >> b) & 1) == 0;
}
}
// data bit layout // data bit layout
uint column = (WIDTH - px - (px < 6)-1)/2; uint column = (WIDTH - px - (px < 6)-1)/2;
uint direction_up = column % 2 == 0; uint direction_up = column % 2 == 0;