{"id":148,"date":"2009-02-06T13:20:18","date_gmt":"2009-02-06T12:20:18","guid":{"rendered":"http:\/\/www.ozone3d.net\/blogs\/lab\/?p=148"},"modified":"2011-09-07T20:43:00","modified_gmt":"2011-09-07T19:43:00","slug":"how-to-linearize-the-depth-value","status":"publish","type":"post","link":"https:\/\/www.ozone3d.net\/blogs\/lab\/20090206\/how-to-linearize-the-depth-value\/","title":{"rendered":"How To Linearize the Depth Value"},"content":{"rendered":"<p>Here is a GLSL code snippet to convert the exponential depth to a linear value:<br \/>\n<code><br \/>\nfloat f=1000.0;<br \/>\nfloat n = 0.1;<br \/>\nfloat z = (2 * n) \/ (f + n - texture2D( texture0, texCoord ).x * (f - n));<br \/>\n<\/code><br \/>\nwhere:<br \/>\n&#8211; f = camera far plane<br \/>\n&#8211; n = camera near plane<br \/>\n&#8211; texture0 = depth map.<\/p>\n<p><a href=\"http:\/\/www.opengl.org\/discussion_boards\/ubbthreads.php?ubb=showflat&#038;Number=236738&#038;#Post236738\">[source]<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a GLSL code snippet to convert the exponential depth to a linear value: float f=1000.0; float n = 0.1; float z = (2 * n) \/ (f + n &#8211; texture2D( texture0, texCoord ).x * (f &#8211; n)); where: &#8211; f = camera far plane &#8211; n = camera near plane &#8211; texture0 = depth map. [source]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[334,18,336,335],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-opengl","tag-depth","tag-glsl","tag-linear","tag-z-buffer"],"aioseo_notices":[],"views":17516,"_links":{"self":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":0,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}