I need the following part of my vertex shader simplified.
Sb=Sb|((gl_VertexID&(128+1))<<9);
Sb=Sb|((gl_VertexID&(512+4))<<6);
Sb=Sb|((gl_VertexID&(2048+16))<<3);
Sb=Sb|(gl_VertexID&(8192+64));
Sb=Sb|((gl_VertexID&(256+32768))>>3);
Sb=Sb|((gl_VertexID&(1024+131072))>>6);
Sb=Sb|((gl_VertexID&(4096+524288))>>9);
Sb=Sb|((gl_VertexID&2)<<18);
Sb=Sb|((gl_VertexID&8)<<15);
Sb=Sb|((gl_VertexID&32)<<12);
Sb=Sb|((gl_VertexID&16384)>>12);
Sb=Sb|((gl_VertexID&65536)>>15);
Sb=Sb|((gl_VertexID&262144)>>18);
I have considered using a lookup table in which case it would be at least 2 MB for the best case I can imagine.
What this code needs to do is to reference in to an array. From Sb I use the last 20 bits. the first 10 of them reference the row and the last 10 them the column. I need these to progress as if they were integral numbers counting up from zero, but read backwards.
The output would look like this:
0000000000 0000000000
1000000000 0000000000
0000000000 1000000000
1000000000 1000000000
0100000000 0000000000
1100000000 0000000000
0100000000 1000000000
1100000000 1000000000
0000000000 0100000000
Edit: Speed is key. This needs to happen very fast... ..but should not use up valuable memory.