Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseTexture.readPixels() support for 3D Textures #14176

Open
christianphalv opened this issue Aug 17, 2023 · 2 comments
Open

BaseTexture.readPixels() support for 3D Textures #14176

christianphalv opened this issue Aug 17, 2023 · 2 comments
Assignees
Milestone

Comments

@christianphalv
Copy link

We only accept feature requests that are discussed on the BabylonJS forum

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.

https://playground.babylonjs.com/#LNRURP#1

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.

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

Discussion

https://forum.babylonjs.com/t/texture-readpixels-only-returns-top-slice-of-3d-textures/43388

@christianphalv
Copy link
Author

Another related enhancement would be to have ThinTexture.getSize() return a depth for 3D and 2DArray Textures.

https://doc.babylonjs.com/typedoc/classes/BABYLON.ThinTexture#getSize

@Popov72 Popov72 added this to the 7.0 milestone Aug 21, 2023
@Popov72 Popov72 self-assigned this Aug 21, 2023
@thomlucc thomlucc modified the milestones: 7.0, Future Jan 9, 2024
@thomlucc thomlucc modified the milestones: Future, 8.0 Mar 12, 2024
Copy link

This issue has been automatically staled because it has been inactive for more than 14 days. Please update to "unstale".

@github-actions github-actions bot added the stale label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants