Skip to content

Instantly share code, notes, and snippets.

@n1ckfg
Last active November 13, 2019 17:36
Show Gist options
  • Select an option

  • Save n1ckfg/9ccd6dada5f80c0feada9cd096e3661a to your computer and use it in GitHub Desktop.

Select an option

Save n1ckfg/9ccd6dada5f80c0feada9cd096e3661a to your computer and use it in GitHub Desktop.
Approximate real-world depth from 8bpc grayscale using Google ODS standard
# https://www.reddit.com/r/6DoF/comments/cmtez9/6dof_compositing_resources/
# Distance in Meters = Minimum Depth Distance in Meters / Greyscale Value
'''
255 = 1m
254 = 1.004m
244 = 1.04m
204 = 1.22m
127 = 1.7m
64 = 2.4m
1 = 6m
0 = 7m
'''
def getGrayscaleDistance(val):
returns = 0.0
maxDistance = 0.0
for i in range(1, 256):
maxDistance += 1.0/i
for i in range(1, val+1):
returns += 1.0/i
return abs(maxDistance - returns) + 1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment