How to properly setup a Texture3D? Understanding Texture3D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By toblin

I’m trying to create a Texture3D as a “mirror” of a cubical lattice (with uniformly spread out points). However, I don’t understand how Texture3D is intended to work.

What are the height, width, and depth parameters? What is the relation between them and the texture layers?

Say that I wish to create a Texture3D with datapoints spread out in a cubicle lattice by 5x5x5. How would I go about doing so?

:bust_in_silhouette: Reply From: Zylann

Texture3D is a 3D texture that will be sampled in 3D by the graphics card, and if filtering is enabled, will interpolate across the 3 dimensions (contrary to a TextureArray).

Godot only has a 2D Image class, so the way it handles 3D textures is by defining them as a series of piled up slices to form a 3D one.

If you want to create a 5x5x5 3D texture, you would create 5 images, each with a width of 5 and height of 5. Then choose your 3D texture to have 5 layers (i.e a depth of 5).

Apparently you already went on doing this by code: How to define data in a Texture3D? Using Image not working - Archive - Godot Forum