@@ -8,14 +8,19 @@ uvec2 nbl_glsl_encodeRGB19E7(in vec3 col)
8
8
const vec3 clamped = clamp (col,vec3 (0.0 ),vec3 (nbl_glsl_MAX_RGB19E7));
9
9
const float maxrgb = max (max (clamped.r,clamped.g),clamped.b);
10
10
11
- const int f32_exp = bitfieldExtract( floatBitsToInt(maxrgb), 23 , 8 ) - 127 ;
12
- const int shared_exp = clamp (f32_exp,- nbl_glsl_RGB19E7_EXP_BIAS,nbl_glsl_MAX_RGB19E7_EXP);
11
+ const int f32_exp = (( floatBitsToInt(maxrgb)>> 23 ) & 0xff) - 127 ;
12
+ const int shared_exp = clamp (f32_exp,- nbl_glsl_RGB19E7_EXP_BIAS- 1 ,nbl_glsl_MAX_RGB19E7_EXP) + 1 ;
13
13
14
- const uvec3 mantissas = uvec3 (clamped* exp2 (nbl_glsl_RGB19E7_MANTISSA_BITS- shared_exp));
14
+ const uvec3 mantissas = uvec3 (clamped* exp2 (nbl_glsl_RGB19E7_MANTISSA_BITS- shared_exp) + 0.5 );
15
15
16
16
uvec2 encoded;
17
17
encoded.x = bitfieldInsert(mantissas.x,mantissas.y,nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[1 ],nbl_glsl_RGB19E7_G_COMPONENT_SPLIT);
18
- encoded.y = bitfieldInsert(mantissas.y>> nbl_glsl_RGB19E7_G_COMPONENT_SPLIT,mantissas.z,nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[2 ],nbl_glsl_RGB19E7_MANTISSA_BITS)| uint ((shared_exp+ nbl_glsl_RGB19E7_EXP_BIAS)<< nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[3 ]);
18
+ encoded.y = bitfieldInsert(
19
+ mantissas.y>> nbl_glsl_RGB19E7_G_COMPONENT_SPLIT,
20
+ mantissas.z,
21
+ nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[2 ],
22
+ nbl_glsl_RGB19E7_MANTISSA_BITS)
23
+ | uint ((shared_exp+ nbl_glsl_RGB19E7_EXP_BIAS)<< nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[3 ]);
19
24
20
25
return encoded;
21
26
}
0 commit comments