robertleeplummerjr / three-js-rgba-packing

Functions to pack and unpack native float and integer types in RGBA textures, along with example and tests.

Repository from Github https://github.comrobertleeplummerjr/three-js-rgba-packingRepository from Github https://github.comrobertleeplummerjr/three-js-rgba-packing

three-js-rgba-packing

Examples work with Three r0.96.0

RGBA Packing

Functions to pack and unpack native float and integer types in RGBA textures, and read them in shaders. Main functions in Javascript and GLSL. Comes with an HTML test page using THREE.JS, to be easily included in your THREE.JS code.

Taken and adapted from : https://stackoverflow.com/questions/18453302/how-do-you-pack-one-32bit-int-into-4-8bit-ints-in-glsl-webgl

Unit Float32 to RGBA Packing

For now this code only provides functions for float32 in range [0;1[ 1.0 is excluded from the range. The maximum number that can be stored is something like 1.0 - 1.e-7.

Full range Float32 to RGBA Packing

No functinons for now. The easier way is probably to use Unit Float32 and map it to a minValue,maxValue range.

Uint32 to RGBA Packing

Todo.

About

Functions to pack and unpack native float and integer types in RGBA textures, along with example and tests.

License:MIT License


Languages

Language:JavaScript 98.7%Language:HTML 1.3%