cleanup
This commit is contained in:
parent
7071a0189d
commit
16305cd3fc
1 changed files with 20 additions and 18 deletions
|
@ -1,8 +1,8 @@
|
||||||
Shader "CrispyPin/QRCode" {
|
Shader "CrispyPin/QRCode" {
|
||||||
Properties {
|
Properties {
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
_("",2D)=""
|
_("",2D)=""{}
|
||||||
_Version("Version", Integer) = 1
|
_Version("Version", Range(1, 40)) = 1
|
||||||
}
|
}
|
||||||
SubShader {
|
SubShader {
|
||||||
Tags { "RenderType"="Opaque" }
|
Tags { "RenderType"="Opaque" }
|
||||||
|
@ -14,6 +14,8 @@ CGPROGRAM
|
||||||
|
|
||||||
#define VERSION _Version
|
#define VERSION _Version
|
||||||
#define WIDTH (17 + VERSION * 4)
|
#define WIDTH (17 + VERSION * 4)
|
||||||
|
#define PIXEL_WIDTH WIDTH
|
||||||
|
// #define PIXEL_WIDTH 177
|
||||||
#define ALIGNERS ((VERSION / 7) + 2)
|
#define ALIGNERS ((VERSION / 7) + 2)
|
||||||
#define ALIGNER_SPACING_IDEAL ((WIDTH - 13) / (ALIGNERS-1))
|
#define ALIGNER_SPACING_IDEAL ((WIDTH - 13) / (ALIGNERS-1))
|
||||||
#define ALIGNER_SPACING (ALIGNER_SPACING_IDEAL + ALIGNER_SPACING_IDEAL % 2)
|
#define ALIGNER_SPACING (ALIGNER_SPACING_IDEAL + ALIGNER_SPACING_IDEAL % 2)
|
||||||
|
@ -40,24 +42,23 @@ CGPROGRAM
|
||||||
|
|
||||||
#define WHITE 1
|
#define WHITE 1
|
||||||
#define BLACK 0
|
#define BLACK 0
|
||||||
#define PINK float4(1, .3, .5, 1)
|
#define PINK float3(1, .3, .5)
|
||||||
#define BLUE float4(0, .4, .7, 1)
|
#define BLUE float3(0, .4, .7)
|
||||||
|
|
||||||
float4 finder_pattern(uint x, uint y) {
|
float3 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);
|
||||||
return (x > 6 || y > 6);
|
return (x > 6 || y > 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 main (float2 uv){
|
float3 main (float2 uv){
|
||||||
const uint data[] = {0x68656c6c,0x6f20776f,0x726c6421};
|
const uint data[] = {0x68656c6c,0x6f20776f,0x726c6421};
|
||||||
uv.y = 1 - uv.y;
|
uv.y = 1 - uv.y;
|
||||||
uv = uv * 1.5 - 0.25;
|
uv = uv * 1.5 - 0.25;
|
||||||
// Quiet zone
|
// Quiet zone
|
||||||
if (uv.x < 0 || uv.x > 1 || uv.y < 0 || uv.y > 1) return 1;
|
if (uv.x < 0 || uv.x > 1 || uv.y < 0 || uv.y > 1) return 1;
|
||||||
|
|
||||||
uint px = uv.x * WIDTH;
|
uint px = uv.x * PIXEL_WIDTH;
|
||||||
uint py = uv.y * WIDTH;
|
uint py = uv.y * PIXEL_WIDTH;
|
||||||
|
|
||||||
|
|
||||||
// Finder patterns
|
// Finder patterns
|
||||||
if (px < 8 && py < 8) return finder_pattern(px, py);
|
if (px < 8 && py < 8) return finder_pattern(px, py);
|
||||||
|
@ -77,14 +78,14 @@ CGPROGRAM
|
||||||
&& (px < WIDTH - 13 || py > 12) // top right
|
&& (px < WIDTH - 13 || py > 12) // top right
|
||||||
&& (py < WIDTH - 13 || px > 12) // bottom left
|
&& (py < WIDTH - 13 || px > 12) // bottom left
|
||||||
) {
|
) {
|
||||||
uint x = px + ALIGNER_SPACING - 4 - MISALIGNMENT;
|
uint x = px + ALIGNER_SPACING - 4;
|
||||||
uint y = py + ALIGNER_SPACING - 4 - MISALIGNMENT;
|
uint y = py + ALIGNER_SPACING - 4;
|
||||||
if (px < 15) x += MISALIGNMENT;
|
if (px > 12) x -= MISALIGNMENT;
|
||||||
if (py < 15) y += MISALIGNMENT;
|
if (py > 12) y -= MISALIGNMENT;
|
||||||
uint ax = x % ALIGNER_SPACING;
|
x %= ALIGNER_SPACING;
|
||||||
uint ay = y % ALIGNER_SPACING;
|
y %= ALIGNER_SPACING;
|
||||||
if (ax < 5 && ay < 5) {
|
if (x < 5 && y < 5) {
|
||||||
return (ax < 4 && ax > 0 && ay < 4 && ay > 0 && !(ax == 2 && ay == 2));
|
return (x < 4 && x > 0 && y < 4 && y > 0 && !(x == 2 && y == 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +105,8 @@ CGPROGRAM
|
||||||
uint direction_up = column & 1;
|
uint direction_up = column & 1;
|
||||||
// return lerp(BLUE, PINK, column / (WIDTH/2.));
|
// return lerp(BLUE, PINK, column / (WIDTH/2.));
|
||||||
return lerp(BLUE, PINK, (px+py)&1);
|
return lerp(BLUE, PINK, (px+py)&1);
|
||||||
// return float4((px/8 + py/8) & 1, (px/2 + py/2) & 1, (px/4 + py/4) & 1, 1);
|
// return float3((px%5)/5., (px/10+py/10)&1, (py%5)/5.);
|
||||||
|
// return float3((px/8 + py/8) & 1, (px/2 + py/2) & 1, (px/4 + py/4) & 1, 1);
|
||||||
// return direction_up;
|
// return direction_up;
|
||||||
return 0.5;
|
return 0.5;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue