• Create Account

### #ActualHodgman

Posted 23 April 2012 - 04:27 AM

Is there a way to pack 2 float values into 1 16-bit float texture color component? Since that way a single GBuffer texture could hold 8 float values of limited accuracy. Somebody said one to use "float output = floor( floatValue1 * 255.0 ) + floatValue2;". Somehow I don't think that would do the trick as 16-bit float is not stored in a way for this to have much of an effect. I presume the sign bit, exponent bits and a couple of value bits would have to be used to store one value and the rest for the second.

I've never done this, but it should be possible. All the required details should be on the wikipedia page on floating point (and on logarithms). I imagine a packing function would look something like:
half PackHalf( float A/*one bit*/, float B/*5 bits*/, float C/*10 bits*/ )//all inputs in 0-1 range

{

float s = A*2-1;// -1/+1

float e = lerp( -13, 14, B );

float f = lerp( 1024, 2047, C );

return s*f*pow(2,e);

}//N.B. most likely contains mistakes

### #3Hodgman

Posted 23 April 2012 - 04:25 AM

Is there a way to pack 2 float values into 1 16-bit float texture color component? Since that way a single GBuffer texture could hold 8 float values of limited accuracy. Somebody said one to use "float output = floor( floatValue1 * 255.0 ) + floatValue2;". Somehow I don't think that would do the trick as 16-bit float is not stored in a way for this to have much of an effect. I presume the sign bit, exponent bits and a couple of value bits would have to be used to store one value and the rest for the second.

I've never done this, but it should be possible. All the required details should be on the wikipedia page on floating point (and on logarithms). I imagine a packing function would look something like:
half PackHalf( float A/*one bit*/, float B/*5 bits*/, float C/*10 bits*/ )//all inputs in 0-1 range

{

float s = A*2-1;// -1/+1

float e = lerp( -13, 14, B );

float f = lerp( 1024, 2047, C );

return s*f*pow(2,e);

}

### #2Hodgman

Posted 23 April 2012 - 04:15 AM

Is there a way to pack 2 float values into 1 16-bit float texture color component? Since that way a single GBuffer texture could hold 8 float values of limited accuracy. Somebody said one to use "float output = floor( floatValue1 * 255.0 ) + floatValue2;". Somehow I don't think that would do the trick as 16-bit float is not stored in a way for this to have much of an effect. I presume the sign bit, exponent bits and a couple of value bits would have to be used to store one value and the rest for the second.

I've never done this, but it should be possible. All the required details should be on the wikipedia page on floating point. I imagine a packing function would look like:
half PackHalf( float A/*one bit*/, float B/*5 bits*/, float C/*10 bits*/ )//all inputs in 0-1 range

{

float s = A*2-1;// -1/+1

float e = lerp( -13, 14, B );

float f = lerp( 1024, 2047, C );

return s*f*pow(2,e);

}

### #1Hodgman

Posted 23 April 2012 - 04:15 AM

Is there a way to pack 2 float values into 1 16-bit float texture color component? Since that way a single GBuffer texture could hold 8 float values of limited accuracy. Somebody said one to use "float output = floor( floatValue1 * 255.0 ) + floatValue2;". Somehow I don't think that would do the trick as 16-bit float is not stored in a way for this to have much of an effect. I presume the sign bit, exponent bits and a couple of value bits would have to be used to store one value and the rest for the second.

I've never done this, but it should be possible. All the required details should be on the wikipedia page on floating point. I imagine a packing function would look like:
half PackHalf( float A/*one bit*/, float B/*5 bits*/, float C/*10 bits*/ )//all inputs in 0-1 range

{

float s = A*2-1;// -1/+1

float e = lerp( -13, 14, B );

float f = lerp( 1024, 2047, C );

return s*f*pow(2,e);

}

PARTNERS