Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question 2Bytes to Float conversion

Discussion in 'General Graphics' started by fwalker, Aug 3, 2023.

  1. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    I am going a little crazy here. Is there really no "official" way to convert 2bytes to a float? Do you really have to roll your own? Seems strange.
    I am trying to look at the contents of the Motion Vector texture which is a R16G16_float texture and see the contents (sp the displacement) as floats. But I have yet to figure out how to do the conversion. I am checking here cause while rolling my own would be fun, how would I know if I am using the correct format? Would using this format be correct?
    https://en.wikipedia.org/wiki/Half-precision_floating-point_format
     
  2. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    179
    You can use method f16tof32 from Unity.Mathematics library.