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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -