if you are planing to use only 4 options you should use fract() and masks
const float inverseNextMSB = 1.0/16.0;
const vec4 bits = vec4( 1.0,2.0,4.0,8.0);
const vec4 mask = vec4(0.5,0.5,0.5,0.0);
void main()
{
float normalizedOpts = options * inverseNextMSB;
vec4 opts = vec4( fract( bits* normalizedOpts ) );
opts -= opts.yzww * mask;
//at this point xyzw represent bits 0:NO, 0.5:YES from MSB to LSB (x: MSB, w:LSB)
...
}
Last thing I should try is to create const vec4 array of all possible combination (dumb but it should work)
If you want to make it fast just make all possible versions of shader and compile it using #define
[quote name='V-man' timestamp='1321720306' post='4885634']
It probably depends on the GPU's capabilities. Perhaps the next generation will have bit manipulation capabilities. Desktop GPUs already have it.
Yeah I'm stuck on GLSL 1.20 at the moment. I ended up using a bool for each option.
[/quote]
There is nothing wrong with using bool and if and else, unless if it gives performance problems on your target GPU. Personally, I would have multiple shader versions.
Sig: http://glhlib.sourceforge.net an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);