Skip to content

Instantly share code, notes, and snippets.

@gamefreak
Created May 9, 2013 10:26
Show Gist options
  • Save gamefreak/5546750 to your computer and use it in GitHub Desktop.
Save gamefreak/5546750 to your computer and use it in GitHub Desktop.
#extension GL_EXT_gpu_shader4 : enable
const int A = 0x23c7;
const int B = 0xe953;
const int C = 0xc207;
const int D = 0xe853;
const int E = 0xc287;
const int F = 0x0287;
const int G = 0xe307;
const int H = 0x23c4;
const int I = 0xc813;
const int J = 0xe240;
const int K = 0x12a4;
const int L = 0xc204;
const int M = 0x226c;
const int N = 0x324c;
const int O = 0xe247;
const int P = 0x03c7;
const int Q = 0xf247;
const int R = 0x13c7;
const int S = 0xe187;
const int T = 0x0813;
const int U = 0xe244;
const int V = 0x0624;
const int W = 0x3644;
const int X = 0x1428;
const int Y = 0x0828;
const int Z = 0xc423;
const int SPACE = 0x0000;
const int ZERO = 0x0e667;
const int ONE = 0x2040;
const int TWO = 0xc3c3;
const int THREE = 0xe1c3;
const int FOUR = 0x21c4;
const int FIVE = 0xd087;
const int SIX = 0x4a85;
const int SEVEN = 0x0423;
//Alternate 7
//const int SEVEN = 0x2043;
const int EIGHT = 0x0e3c7;
const int NINE = 0xe1c7;
int identifySegments(vec2 pos) {
const float thick = 0.1;
if (0.0 > pos.x || pos.x > 1.0 || 0.0 > pos.y || pos.y > 1.0) {
return 0x0000;
}
int code = 0;
if (pos.x < thick) {
//Left Bar
if (pos.y < 0.5) code |= 0x004; else code |= 0x0200;;
}
if (pos.x > 1.0 - thick) {
//Right Bar
if (pos.y < 0.5) code |= 0x0040; else code |= 0x2000;
}
if ((0.5 - thick < pos.x) && (pos.x < 0.5 + thick)) {
//Center Bar
if (pos.y < 0.5) code |= 0x0010; else code |= 0x0800;
}
if (pos.y < thick) {
//Top Bar
if (pos.x < 0.5) code |= 0x0001; else code |= 0x0002;
}
if (pos.y > 1.0 -thick) {
if (pos.x < 0.5) code |= 0x4000; else code |= 0x8000;
}
if ((0.5 - thick < pos.y) && (pos.y < 0.5 + thick)) {
if (pos.x < 0.5) code |= 0x0080; else code |= 0x0100;
}
if (abs(pos.y-pos.x)<thick) {
if (pos.y < 0.5) code |= 0x0008; else code |= 0x1000;
}
if (abs(pos.y+pos.x-1.0)<thick) {
if (pos.y < 0.5) code |= 0x0020; else code |= 0x0400;
}
return code;
}
int take_one[32];
int bottles[15];
int the_wall[11];
int numbers[10];
void init() {
take_one[0] = T;
take_one[1] = A;
take_one[2] = K;
take_one[3] = E;
take_one[4] = SPACE;
take_one[5] = O;
take_one[6] = N;
take_one[7] = E;
take_one[8] = SPACE;
take_one[9] = D;
take_one[10] = O;
take_one[11] = W;
take_one[12] = N;
take_one[13] = SPACE;
take_one[14] = A;
take_one[15] = N;
take_one[16] = D;
take_one[17] = SPACE;
take_one[18] = P;
take_one[19] = A;
take_one[20] = S;
take_one[21] = S;
take_one[22] = SPACE;
take_one[23] = I;
take_one[24] = T;
take_one[25] = SPACE;
take_one[26] = A;
take_one[27] = R;
take_one[28] = O;
take_one[29] = U;
take_one[30] = N;
take_one[31] = D;
bottles[0] = B;
bottles[1] = O;
bottles[2] = T;
bottles[3] = T;
bottles[4] = L;
bottles[5] = E;
bottles[6] = S;
bottles[7] = SPACE;
bottles[8] = O;
bottles[9] = F;
bottles[10] = SPACE;
bottles[11] = B;
bottles[12] = E;
bottles[13] = E;
bottles[14] = R;
the_wall[0] = O;
the_wall[1] = N;
the_wall[2] = SPACE;
the_wall[3] = T;
the_wall[4] = H;
the_wall[5] = E;
the_wall[6] = SPACE;
the_wall[7] = W;
the_wall[8] = A;
the_wall[9] = L;
the_wall[10] = L;
numbers[0] = ZERO;
numbers[1] = ONE;
numbers[2] = TWO;
numbers[3] = THREE;
numbers[4] = FOUR;
numbers[5] = FIVE;
numbers[6] = SIX;
numbers[7] = SEVEN;
numbers[8] = EIGHT;
numbers[9] = NINE;
}
const int take_one_len = 32;
const int bottles_len = 15;
const int the_wall_len = 11;
const int total_len = 113;
int get_char(int row, int char) {
row = 99 - row ;
if (row <=0) {
return SPACE;
}
if (char == 0) {
if (row >= 10)
return numbers[row/10];
else
return SPACE;
}
if (char == 1) return numbers[row%10];
if (char == 2) return SPACE;
char -= 3;
if (char < bottles_len) return bottles[char];
if (char == bottles_len) return SPACE;
char -= bottles_len + 1;
if (char < the_wall_len) return the_wall[char];
if (char == the_wall_len) return SPACE;
char -= the_wall_len + 1;
if (char == 0) return numbers[row/10];
if (char == 1) return numbers[row%10];
if (char == 2) return SPACE;
char -= 3;
if (char < bottles_len) return bottles[char];
if (char == bottles_len) return SPACE;
char -= bottles_len + 1;
if (char < take_one_len) return take_one[char];
if (char == take_one_len) return SPACE;
char -= take_one_len + 1;
if (char == 0) {
if (row >= 11)
return numbers[(row-1)/10];
else
return SPACE;
}
if (char == 1) return numbers[(row-1)%10];
if (char == 2) return SPACE;
char -= 3;
if (char < bottles_len) return bottles[char];
if (char == bottles_len) return SPACE;
char -= bottles_len + 1;
if (char < the_wall_len) return the_wall[char];
if (char == the_wall_len) return SPACE;
char -= the_wall_len + 1;
return SPACE;
}
void main() {
init();
vec2 pos = gl_TexCoord[0].st * float(total_len);
int char = get_char(int(pos.t), int(pos.s));
if ((char & identifySegments(mod(pos,1.0)*1.1-0.05)) > 0) {
gl_FragColor = vec4(0.0,0.0,0.0,1);
} else {
gl_FragColor = vec4(1.0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment