Hi
Just got an idea, how one could improve the precision of normalization cubemaps a bit. It´s no big deal, but i´d like to know your opinion.
The thing is, that in a typical cubemap you store the sign of the vector by putting the vector into [0,1] range. This means, that in a texture with 8 Bit per channel, one bit gets “wasted”.
I thought, that this one bit could be saved, and used for more precision, because we already have the sign - inside the texture coordinate.
So i store my normals with absolute values, which means, that every channel can now really hold a value between 0…255 instead of -128…127.
I don´t know, if this makes a visual difference, i couldn´t see much, but i´ll have to test it a bit more.
Since the ARB_fragment_program extension does not have a SIGN function, this becomes a bit more difficult, than i thought. Well, here is my code:
#to be normalised:
#vVector
#normalise it
TEMP vVectorNorm;
TEX vVectorNorm, vVector, texture[2], CUBE;
TEMP sgn, zero;
MOV zero, {0.0, 0.0, 0.0, 0.0};
#set to 1.0 on greater or equal to 0.0 else set to 0.0
SGE sgn, vVector, zero;
#put the signs into [-1, 1] range
MAD sgn, sgn, 2.0, -1.0;
#multiply each component with its sign
MUL vVectorNorm, vVectorNorm, sgn;
Well, most of the code simpy emulates the SIGN function. Since glSlang does now this function, there the code should be much shorter.
Jan.