playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
3 lines (2 loc) • 1.02 kB
TypeScript
declare const _default: "\n\n#ifndef FLOAT_AS_UINT\n#define FLOAT_AS_UINT\n\n// encode float value to RGBA8\nvec4 float2uint(float value) {\n uint intBits = floatBitsToUint(value);\n return vec4(\n float((intBits >> 24u) & 0xFFu) / 255.0,\n float((intBits >> 16u) & 0xFFu) / 255.0,\n float((intBits >> 8u) & 0xFFu) / 255.0,\n float(intBits & 0xFFu) / 255.0\n );\n}\n\n// decode RGBA8 value to float\nfloat uint2float(vec4 value) {\n uint intBits = \n (uint(value.r * 255.0) << 24u) |\n (uint(value.g * 255.0) << 16u) |\n (uint(value.b * 255.0) << 8u) |\n uint(value.a * 255.0);\n\n return uintBitsToFloat(intBits);\n}\n\n// store a single float value in vec4, assuming either RGBA8 or float renderable texture\nvec4 float2vec4(float value) {\n #if defined(CAPS_TEXTURE_FLOAT_RENDERABLE)\n return vec4(value, 1.0, 1.0, 1.0);\n #else\n return float2uint(value);\n #endif\n}\n\n#endif // FLOAT_AS_UINT\n";
export default _default;