Skip to content
Snippets Groups Projects
Commit 0bfb05de authored by Alexander Rose's avatar Alexander Rose
Browse files

added de/encodeFloatRGBA glsl helper functions

parent bf3a6846
Branches
Tags
No related merge requests found
float decodeFloatRGBA(vec4 rgba) {
return dot(rgba, vec4(1.0, 1/255.0, 1/65025.0, 1/16581375.0));
}
#pragma glslify: export(decodeFloatRGBA)
\ No newline at end of file
vec4 encodeFloatRGBA(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = frac(enc);
enc -= enc.yzww * float4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);
return enc;
}
#pragma glslify: export(encodeFloatRGBA)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment