qr shader: correct data bit order, everywhere hopefully
This commit is contained in:
parent
5f839b88ae
commit
100b7e0953
1 changed files with 103 additions and 43 deletions
|
@ -34,7 +34,8 @@ CGPROGRAM
|
||||||
#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)
|
||||||
#define MISALIGNMENT ((WIDTH - 13) - ALIGNER_SPACING * ALIGNERS)
|
#define MISALIGNMENT ((WIDTH - 13) - ALIGNER_SPACING * ALIGNERS)
|
||||||
#define BIT_COUNT (WIDTH * WIDTH - 225 - (WIDTH - 17)*2 - 25 * (ALIGNERS * ALIGNERS - 3) * (VERSION > 1))
|
#define ALIGNER_COUNT ((ALIGNERS * ALIGNERS - 3) * (VERSION > 1))
|
||||||
|
#define BIT_COUNT (WIDTH * WIDTH - 225 - (WIDTH - 17)*2 - 25 * ALIGNER_COUNT + 10*(ALIGNERS-2)*(ALIGNERS>2) - 36 * (VERSION > 6))
|
||||||
#define TIME_MANUAL (_TimeSlider + _TimeSliderCoarse*100)
|
#define TIME_MANUAL (_TimeSlider + _TimeSliderCoarse*100)
|
||||||
#define TIME (uint)(_Animate ? _Time.y * _AnimationSpeed + TIME_MANUAL : TIME_MANUAL)
|
#define TIME (uint)(_Animate ? _Time.y * _AnimationSpeed + TIME_MANUAL : TIME_MANUAL)
|
||||||
|
|
||||||
|
@ -167,8 +168,22 @@ CGPROGRAM
|
||||||
// aligners always cover a half column to the left and two full columns to the right
|
// aligners always cover a half column to the left and two full columns to the right
|
||||||
// outer aligners are always 4 from all edges
|
// outer aligners are always 4 from all edges
|
||||||
|
|
||||||
|
if (VERSION > 6) {
|
||||||
|
// top version info section
|
||||||
|
if (column == 5){
|
||||||
|
bit_index -= 12;
|
||||||
|
bit_index -= min(py + 1, 6);
|
||||||
|
} else if (column > 5) {
|
||||||
|
bit_index -= 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint aligner_col = (column - 2) / (ALIGNER_SPACING/2);
|
uint aligner_col = (column - 2) / (ALIGNER_SPACING/2);
|
||||||
uint aligner_col_mod = (column - 2) % (ALIGNER_SPACING/2);
|
uint aligner_col_mod = (column - 2) % (ALIGNER_SPACING/2);
|
||||||
|
if (aligner_col > (ALIGNERS - 2)){
|
||||||
|
aligner_col_mod = (column-2) - (aligner_col-1) * (ALIGNER_SPACING/2);
|
||||||
|
aligner_col -= 1;
|
||||||
|
}
|
||||||
if (aligner_col > 0) { // full columns passed
|
if (aligner_col > 0) { // full columns passed
|
||||||
bit_index -= (ALIGNERS - 1) * aligner_col*25;
|
bit_index -= (ALIGNERS - 1) * aligner_col*25;
|
||||||
if (aligner_col > 1) {
|
if (aligner_col > 1) {
|
||||||
|
@ -177,62 +192,107 @@ CGPROGRAM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint passed_up = (y_relative - 9 + ALIGNER_SPACING - (!direction_up * (MISALIGNMENT+ALIGNER_SPACING))) / ALIGNER_SPACING;
|
uint passed_up = min((y_relative - 9 + ALIGNER_SPACING)/ALIGNER_SPACING, ALIGNERS-1);
|
||||||
passed_up = min(passed_up, ALIGNERS-1);
|
|
||||||
|
#define ALIGNER_GRID_Y_START (WIDTH - 9 - ALIGNER_SPACING * (ALIGNERS - 1))
|
||||||
|
|
||||||
|
uint passed_down = py > ALIGNER_GRID_Y_START ? (py - ALIGNER_GRID_Y_START) / ALIGNER_SPACING : 0;
|
||||||
|
|
||||||
|
if (px < 9) {
|
||||||
|
if (passed_up>0) passed_up -= 1;
|
||||||
|
if (passed_down>(ALIGNERS-2)) passed_down-=1;
|
||||||
|
// if (passed_down>0) return 5;
|
||||||
|
// if (passed_up>0) return 5;
|
||||||
|
if (tiny_columns == 0) {
|
||||||
|
bit_index -= passed_up*10;
|
||||||
|
} else if (tiny_columns == 1) {
|
||||||
|
// bit_index += 16;
|
||||||
|
bit_index -= passed_down*10;
|
||||||
|
bit_index -= (ALIGNERS-2)*10;
|
||||||
|
} else if (tiny_columns == 2) {
|
||||||
|
if (VERSION > 6) {
|
||||||
|
bit_index -= 12;
|
||||||
|
}
|
||||||
|
bit_index -= (ALIGNERS-2) * 20;
|
||||||
|
} else if (tiny_columns == 3) {
|
||||||
|
if (VERSION > 6) {
|
||||||
|
bit_index -= 12;
|
||||||
|
bit_index -= (ALIGNERS-2)*20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (aligner_col_mod == 0) {
|
if (aligner_col_mod == 0) {
|
||||||
|
if (direction_up) {
|
||||||
bit_index -= passed_up * 10;
|
bit_index -= passed_up * 10;
|
||||||
if (direction_up && py < 5){
|
if (py < 8)
|
||||||
|
bit_index -= 8;
|
||||||
|
} else {
|
||||||
|
bit_index -= passed_down * 10;
|
||||||
|
if (py > 8)
|
||||||
bit_index -= 8;
|
bit_index -= 8;
|
||||||
}
|
|
||||||
if (!direction_up && py > 5){
|
|
||||||
bit_index += 2;
|
|
||||||
if (py > WIDTH-5){
|
|
||||||
bit_index -= 10;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (aligner_col_mod == 1) {
|
} else if (aligner_col_mod == 1) {
|
||||||
uint passed_down = (y_relative - 8 + ALIGNER_SPACING - !direction_up*MISALIGNMENT) / ALIGNER_SPACING;
|
if (column > 3){
|
||||||
bit_index -= (passed_down + ALIGNERS - 1) * 10;
|
bit_index -= ALIGNERS*10 - 2;
|
||||||
if (!direction_up)
|
} else {
|
||||||
bit_index += 10;
|
bit_index -= ALIGNERS*10;
|
||||||
if (aligner_col > 0) {
|
bit_index += 26; // right finder
|
||||||
|
}
|
||||||
|
if (direction_up){
|
||||||
|
bit_index -= passed_up*10;
|
||||||
|
if (py < 5)
|
||||||
bit_index -= 8;
|
bit_index -= 8;
|
||||||
} else {
|
} else {
|
||||||
bit_index += 8;
|
bit_index -= passed_down*10;
|
||||||
|
if (py > 8)
|
||||||
|
bit_index -= 8;
|
||||||
|
if (column == 3)
|
||||||
|
bit_index -= 8;
|
||||||
}
|
}
|
||||||
if (direction_up ? py < 5 : py > 5){
|
} else if (aligner_col_mod == 2 && px > 5) {
|
||||||
bit_index += 2;
|
|
||||||
}
|
|
||||||
} else if (aligner_col_mod == 2) {
|
|
||||||
bit_index -= (ALIGNERS - 1) * 20;
|
bit_index -= (ALIGNERS - 1) * 20;
|
||||||
if (aligner_col > 0) {
|
if (aligner_col > 0)
|
||||||
bit_index -= 16; // most of the current column top aligner, excluding the left 4 pixels
|
bit_index -= 16; // most of the current column top aligner, excluding the left 4 pixels
|
||||||
if (py < 9) {// top aligner
|
|
||||||
if (direction_up) {
|
if (direction_up) {
|
||||||
bit_index -= min(9-py, 5) - (py < 6);
|
bit_index -= passed_up*5;
|
||||||
} else if (py > 3) {
|
uint progress = (y_relative - 4) % ALIGNER_SPACING;
|
||||||
bit_index -= py - 3 - (py > 6);
|
if (y_relative - 4 >= ALIGNER_SPACING*(ALIGNERS-1)) {
|
||||||
|
progress = 999;
|
||||||
|
}
|
||||||
|
if (progress < 5) {
|
||||||
|
bit_index -= progress+1;
|
||||||
|
}
|
||||||
|
if (py < 9) {
|
||||||
|
if (py < 4)
|
||||||
|
bit_index -= 4;
|
||||||
|
else
|
||||||
|
bit_index -= (9-py) - (py<6);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bit_index += !direction_up;
|
bit_index -= passed_down*5;
|
||||||
|
if (py < 6 && py > 3) {
|
||||||
|
bit_index -= py-3;
|
||||||
}
|
}
|
||||||
if (!direction_up && py > WIDTH-5){
|
else if (py < 9 && py > 6) {
|
||||||
bit_index-=5;
|
bit_index -= py-4;
|
||||||
|
} else if (py > 8){
|
||||||
|
bit_index -= 4;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
uint offset = (column_progress + ALIGNER_SPACING - 3 - !direction_up*0 + (!direction_up * (-MISALIGNMENT+1))) % ALIGNER_SPACING;
|
|
||||||
|
|
||||||
// left side of regular aligners
|
uint progress = (py - ALIGNER_GRID_Y_START) % ALIGNER_SPACING;
|
||||||
if (offset < 6 && py > 9 && px > 9) {
|
if (py < WIDTH-((ALIGNERS-1)*ALIGNER_SPACING+4)) {
|
||||||
bit_index -= offset;
|
progress = 999;
|
||||||
|
}
|
||||||
|
if (progress < 5) {
|
||||||
|
bit_index -= progress;
|
||||||
|
bit_index += 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bit_index -= passed_up * 5;
|
|
||||||
|
|
||||||
} else { // include the full row
|
} else if (aligner_col_mod > 2) { // include the full column of aligners
|
||||||
bit_index -= (ALIGNERS - 1)*25;
|
bit_index -= (ALIGNERS - 1)*25;
|
||||||
if (aligner_col > 0){
|
if (aligner_col > 0){
|
||||||
// return PINK;
|
|
||||||
bit_index -= 20;
|
bit_index -= 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,7 +349,7 @@ CGPROGRAM
|
||||||
const uint length = 6;
|
const uint length = 6;
|
||||||
if (worm == 0) return float3(3,0,0);
|
if (worm == 0) return float3(3,0,0);
|
||||||
if (worm < length) return lerp(PINK, BLUE, (worm/(float)length));
|
if (worm < length) return lerp(PINK, BLUE, (worm/(float)length));
|
||||||
if (bit_index > BIT_COUNT) return float3(1,0,0);
|
if (bit_index >= BIT_COUNT) return float3(1,0,0);
|
||||||
// #define BIT_COUNT 24
|
// #define BIT_COUNT 24
|
||||||
return (float)(bit_index%BIT_COUNT)/(float)BIT_COUNT;
|
return (float)(bit_index%BIT_COUNT)/(float)BIT_COUNT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue