# How to convert the depthTexture into the distance of the threejs world

**URL:** <https://discourse.threejs.org/t/how-to-convert-the-depthtexture-into-the-distance-of-the-threejs-world/35403>\
**Category:** Questions\
**Tags:** depth-texture\
**Created:** [February 28, 2022, 11:20am UTC](https://discourse.threejs.org/t/how-to-convert-the-depthtexture-into-the-distance-of-the-threejs-world/35403 "2022-02-28T11:20:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![li\_danyang](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/li_danyang/32/24521_2.png) [@li\_danyang](https://discourse.threejs.org/u/li_danyang)\
**Post date:** [February 28, 2022, 11:20am UTC](https://discourse.threejs.org/t/how-to-convert-the-depthtexture-into-the-distance-of-the-threejs-world/35403/1 "2022-02-28T11:20:17Z")

</div>

How to convert the DepthTexture into the distance of the threejs world.  
I want to get the specific depth distance of a pixel in the DepthTexture. How can I get it?

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [February 28, 2022, 11:29am UTC](https://discourse.threejs.org/t/how-to-convert-the-depthtexture-into-the-distance-of-the-threejs-world/35403/2 "2022-02-28T11:29:06Z")

</div>

> [@li\_danyang](#):
>
> into the distance of the threejs world.

I guess you mean the distance in world units. If so, you find the code for this in: [three.js webgl - Depth Texture](https://threejs.org/examples/webgl_depth_texture)

The value you want to use is the result of `perspectiveDepthToViewZ()` (assuming you are using a perspective camera).

---

<div class="post-metadata">

**Author:** ![li\_danyang](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/li_danyang/32/24521_2.png) [@li\_danyang](https://discourse.threejs.org/u/li_danyang)\
**Post date:** [February 28, 2022, 11:32am UTC](https://discourse.threejs.org/t/how-to-convert-the-depthtexture-into-the-distance-of-the-threejs-world/35403/3 "2022-02-28T11:32:04Z")

</div>

Thank you. I’ll try.
