playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
29 lines (28 loc) • 979 B
TypeScript
/**
* Utility static class providing functionality to pack float values to various storage
* representations.
*
* @category Math
*/
export class FloatPacking {
/**
* Packs a float to a 16-bit half-float representation used by the GPU.
*
* @param {number} value - The float value to pack.
* @returns {number} The 16-bit half-float representation as an integer.
* @example
* const half = pc.FloatPacking.float2Half(1.5);
*/
static float2Half(value: number): number;
/**
* Converts bits of a 32-bit float into RGBA8 format and stores the result in a provided color.
* The float can be reconstructed in shader using the uintBitsToFloat instruction.
*
* @param {number} value - The float value to convert.
* @param {Color} data - The color to store the RGBA8 packed value in.
*
* @ignore
*/
static float2RGBA8(value: number, data: Color): void;
}
import type { Color } from './color.js';