xna - Packing a 16-bit floating point variable into two 8-bit variables (aka half into two bytes) -
i code on xna , has access shader model 3, hence no bitshift operators. need pack 2 random 16-bit floating point variables (meaning not in range [0,1] random float variable) 2 8-bit variables. there no way normalize them.
i thought doing bitshifting manually can't find article on how convert random decimal float (not [0,1]) binary , back. thanks
this not idea - 16-bit float has limited range , precision. remember 8-bits leaves 256 possible values!
getting 8-bit value shader trivial. colour 1 method. can use each channel normalised range, 0 1.
of course, don't want normalise values. assume want maintain nice floating-point property of wide range better precision closer zero.
(now time read background info on floating-point. half-precision floating-point , minifloats and microfloats.)
one way encode values using logarithm , exponent (to encode , decode, respectivly). floating-point format does. exact maths depend on precision , range desire - (which 256 values represent?) - leave exercise.
Comments
Post a Comment