I've edited this post and the thread name a bit, now that I've worked out what people search for.
I've worked out the following HLSL code to turn a float value between 0 and 1 into 3 components ready to write to an 8-bit RGB texture:
const float max24int = 256*256*256-1;
float3 decomp = floor( value * float3( max24int/(256*256), max24int/256, max24int ) ) / 255.0;
decomp.z -= decomp.y * 256.0;
decomp.y -= decomp.x * 256.0;
The recomposition on the other end is the usual dot product:
float value = dot( decomp.xyz, float3( 255.0/256, 255.0/(256*256), 255.0/(256*256*256) ) );
Obviously the recomposition is about as good as it gets but I feel that there might be a better way to decompose than what I have above.
[Edited by - Slagh on March 3, 2008 6:33:31 PM]