Convert depth index of Data3Texture to z-coordinate of NDC

57 Views Asked by At

I want to clip a Data3DTexture (with width, height, depth) at a specific depth, so only render at this depth position and hide all other layers.

I adapt the clipping method from this idea (text ) to VolumeShader provided in ThreeJs.

The volume shader code to change: text

So I compute the color, only at this depth. In cast_mip functions ( and cast_iso ), break the loop for all points outside this depth. As following:

if (loc.z < a_depth_index ) break;

a_depth_index: in [0, depth]

The problem is loc.z is in NDC coordinante, so [0, -1].

How can I convert a depth index of Data3DTexture to NDC z-coordinate, please ?

I saw this post text. But it seems to be good for 2D, not for 3D neither depth position.

Thank you for any help.

0

There are 0 best solutions below