Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ncode:
- depth in [0,1]
- depth *= 1 - 1 / (256 * 256 * 256 * 256)
- depth in [0,1[
- exp = 0
- while(depth < 1){
- depth *= 2;
- exp += 1;
- }
- depth *= 256.0
- depth0 = floor(depth)
- depth = frac(depth)
- depth *= 256.0
- depth1 = floor(depth)
- depth = frac(depth)
- depth *= 256.0
- depth2 = floor(depth)
- depth = frac(depth)
- output : [depth0 / 255.0, depth1 / 255.0, depth2 / 255.0]
- ###############
- decode:
- [depth0, depth1, depth2, exp]
- depth = depth0 * 255.0 / 256.0 + depth1 * 255.0 / (256.0 * 256.0) + depth2 * 255.0 / (256.0 * 256.0 * 256.0)
- while exp != 0 {
- depth = depth / 2;
- exp -= 1;
- }
- 16M [0,1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement