# BaseTexture.readPixels() support for 3D Textures

**URL:** <https://forum.babylonjs.com/t/basetexture-readpixels-support-for-3d-textures/56112>\
**Category:** Feature requests\
**Created:** [January 21, 2025, 7:31pm UTC](https://forum.babylonjs.com/t/basetexture-readpixels-support-for-3d-textures/56112 "2025-01-21T19:31:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomlucc](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/thomlucc/32/4046_2.png) [@thomlucc](https://forum.babylonjs.com/u/thomlucc)\
**Post date:** [January 21, 2025, 7:31pm UTC](https://forum.babylonjs.com/t/basetexture-readpixels-support-for-3d-textures/56112/1 "2025-01-21T19:31:06Z")

</div>

**Is your feature request related to a problem? Please describe.**

I noticed that when I call Texture.readPixels() on a 3D texture, it only returns a buffer containing top 2D slice of pixel data. In the linked example, I create a 2x2x2 3D texture a fill it iteratively with data. I then log the data array and see the expected 2 x 2 x 2 x 4 = 32 data points. After the data is fed to a RawTexture3D, I read the textures pixels but only see the first 16 data points.

> **[Babylon.js Playground](https://playground.babylonjs.com/#LNRURP%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

According to @Evgeni_Popov, reading anything other than the top layer of a 3D texture is not supported.

**Describe the solution you’d like**

I need some way of accessing all the pixel data in a 3D texture. This could be achieved by either updating the current BaseTexture.readPixels() method to return all (or specified) layers of the 3D texture or creating a new RawTexture3D.readPixels3D() method on Rawtexture3D. I would lean toward updating BaseTexture.readPixels() or even creating a new method on BaseTexture that could bring 2D, 2DArray, and 3D textures to parity. Below is an example of such a method.

```auto
readPixelData(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean, noDataConversion?: boolean, x?: number, y?: number, z?: number, width?: number, height?: number, depth?: number): Nullable<Promise<ArrayBufferView>>

```

[https://doc.babylonjs.com/typedoc/classes/BABYLON.BaseTexture#readPixels](https://doc.babylonjs.com/typedoc/classes/BABYLON.BaseTexture#readPixels)

**Discussion**

> [@Texture.readPixels() only returns top slice of 3D textures](https://forum.babylonjs.com/t/texture-readpixels-only-returns-top-slice-of-3d-textures/43388):
>
> I noticed that when I call readPixels() on a 3D texture, it only returns a buffer containing top 2D slice of pixel data. In the linked example, I create a 2x2x2 3D texture a fill it iteratively with data. I then log the data array and see the expected 2 x 2 x 2 x 4 = 32 data points. After the data is fed to a RawTexture3D, I read the textures pixels but only see the first 16 data points. I’m not sure if this should be considered a bug or a feature request. On one hand, it seems like the readP…

\***[Ported](https://github.com/BabylonJS/Babylon.js/issues/14176) From GitHub**
