Created
August 20, 2012 15:18
-
-
Save mzgoddard/3405102 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// packing a float in glsl with multiplication and fract | |
vec4 packFloat( float depth ) { | |
const vec4 bit_shift = vec4( | |
256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 ); | |
const vec4 bit_mask = vec4( | |
0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 ); | |
// fract is the problem | |
vec4 res = fract( depth * bit_shift ); | |
res -= res.xxyz * bit_mask; | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment