encoding - Pack two floats within range into one float -
in hlsl, how go packing 2 floats within range of 0-1 1 float optimal precision. incredibly useful compress gbuffer further.
//packing float = 0.45; float b = 0.55; uint ascaled = * 0xffff; uint bscaled = b * 0xffff; uint abpacked = (ascaled << 16) | (bscaled & 0xffff); float finalfloat = asfloat(abpacked); //unpacking float inputfloat = finalfloat; uint uintinput = asuint(inputfloat); float aunpacked = (uintinput >> 16) / 65535.0f; float bunpacked = (uintinput & 0xffff) / 65535.0f;
Comments
Post a Comment