qr shader: add ec level and mask type bits
This commit is contained in:
parent
f6f7c03c14
commit
f3f3f305e8
2 changed files with 19 additions and 12 deletions
|
@ -61,7 +61,7 @@ Material:
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
m_Ints:
|
m_Ints:
|
||||||
- _Version: 63
|
- _Version: 15
|
||||||
m_Floats:
|
m_Floats:
|
||||||
- _BumpScale: 1
|
- _BumpScale: 1
|
||||||
- _Cutoff: 0.5
|
- _Cutoff: 0.5
|
||||||
|
|
|
@ -12,13 +12,16 @@ CGPROGRAM
|
||||||
struct Input{float2 uv_;};
|
struct Input{float2 uv_;};
|
||||||
uint _Version;
|
uint _Version;
|
||||||
|
|
||||||
// #define VERSION 15
|
|
||||||
#define VERSION _Version
|
#define VERSION _Version
|
||||||
#define WIDTH (21 + (VERSION-1)*4)
|
#define WIDTH (17 + VERSION * 4)
|
||||||
#define ALIGNERS ((VERSION / 7) + 2)
|
#define ALIGNERS ((VERSION / 7) + 2)
|
||||||
#define ALIGNER_SPACING ((WIDTH - 8 - 5) / (ALIGNERS-1))
|
#define ALIGNER_SPACING ((WIDTH - 13) / (ALIGNERS-1))
|
||||||
#define MISALIGNMENT ((WIDTH - 13) % (ALIGNERS-1))
|
#define MISALIGNMENT ((WIDTH - 13) % (ALIGNERS-1))
|
||||||
|
|
||||||
|
#define EC_LEVEL (3)
|
||||||
|
#define MASK_TYPE (4)
|
||||||
|
#define FORMAT_BITS ((EC_LEVEL << 3) | MASK_TYPE)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
v = 15
|
v = 15
|
||||||
width = 77
|
width = 77
|
||||||
|
@ -29,6 +32,7 @@ CGPROGRAM
|
||||||
#define WHITE 1
|
#define WHITE 1
|
||||||
#define BLACK 0
|
#define BLACK 0
|
||||||
#define PINK float4(1, .3, .5, 1)
|
#define PINK float4(1, .3, .5, 1)
|
||||||
|
#define BLUE float4(0, .4, .7, 1)
|
||||||
|
|
||||||
float4 finder_pattern(uint x, uint y) {
|
float4 finder_pattern(uint x, uint y) {
|
||||||
if (x < 6 && x > 0 && y < 6 && y > 0) return !(x < 5 && x > 1 && y < 5 && y > 1);
|
if (x < 6 && x > 0 && y < 6 && y > 0) return !(x < 5 && x > 1 && y < 5 && y > 1);
|
||||||
|
@ -51,6 +55,9 @@ CGPROGRAM
|
||||||
if (px < 8 && py > WIDTH - 9) return finder_pattern(px, py - WIDTH + 7);
|
if (px < 8 && py > WIDTH - 9) return finder_pattern(px, py - WIDTH + 7);
|
||||||
if (px > WIDTH - 9 && py < 8) return finder_pattern(px - WIDTH + 7, py);
|
if (px > WIDTH - 9 && py < 8) return finder_pattern(px - WIDTH + 7, py);
|
||||||
|
|
||||||
|
// filler pixel
|
||||||
|
if (px == 8 && py == WIDTH - 8) return 0;
|
||||||
|
|
||||||
// Timing patterns
|
// Timing patterns
|
||||||
if (px == 6) return py & 1;
|
if (px == 6) return py & 1;
|
||||||
if (py == 6) return px & 1;
|
if (py == 6) return px & 1;
|
||||||
|
@ -75,25 +82,25 @@ CGPROGRAM
|
||||||
// }
|
// }
|
||||||
uint ax = x % ALIGNER_SPACING;
|
uint ax = x % ALIGNER_SPACING;
|
||||||
uint ay = y % ALIGNER_SPACING;
|
uint ay = y % ALIGNER_SPACING;
|
||||||
if (ax < 5 && ay < 5){
|
if (ax < 5 && ay < 5) {
|
||||||
// return PINK;
|
|
||||||
// return (ax|ay) & 1;
|
|
||||||
return (ax < 4 && ax > 0 && ay < 4 && ay > 0 && !(ax == 2 && ay == 2));
|
return (ax < 4 && ax > 0 && ay < 4 && ay > 0 && !(ax == 2 && ay == 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Format bits
|
// Format bits
|
||||||
if (px == 8 && (py < 9 || py > WIDTH - 9)) return 0.8;
|
if (px < 5 && py == 8) return (FORMAT_BITS & (1 << (4 - px))) == 0;
|
||||||
if (py == 8 && (px < 9 || px > WIDTH - 9)) return 0.8;
|
if (px == 8 && py > WIDTH - 6) return (FORMAT_BITS & (1 << py + 5 - WIDTH)) == 0;
|
||||||
|
|
||||||
|
if (px == 8 && (py < 9 || py > WIDTH - 9)) return PINK;
|
||||||
|
if (py == 8 && (px < 9 || px > WIDTH - 9)) return PINK;
|
||||||
|
|
||||||
uint column = (WIDTH - px - (px > 6))/2;
|
uint column = (WIDTH - px - (px > 6))/2;
|
||||||
uint direction_up = column & 1;
|
uint direction_up = column & 1;
|
||||||
return column / 10.;
|
return lerp(BLUE, PINK, column / (WIDTH/2.));
|
||||||
// return direction_up;
|
// return direction_up;
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void s (Input IN, inout SurfaceOutputStandard o) {o.Albedo = main(IN.uv_); }
|
void s (Input IN, inout SurfaceOutputStandard o) { o.Albedo = main(IN.uv_); }
|
||||||
ENDCG
|
ENDCG
|
||||||
}}
|
}}
|
Loading…
Reference in a new issue