A teacher of mine explained to me that a sampler3D is nothing more than a buffer whose information is arranged in a certain “format” so that the API can understand it. So for example, I can “transform” my octree into a non-recursive data structure, an array for example, and later on send that “buffer” successfully to the shader (as a sampler3D), if the data is arranged properly.
So my question is the following, how is my data supposed to be arranged in Panda so that I can send it as a sample3D to a fragment shader? Will Panda take care of the “format” regardless of the API being used?
Can my 3D texture be represented in Python by a simple list / tuple?
Thank you very much, and sorry if my question doesn’t make sense (I’m new at using 3d textures)
Actually what you are talking about I think it’s called a samplerCUBE which is not the same as sampler3D. If I am not mistaken sampler cubes are used for things such as skyboxes, but what I need is something like this:
Apparently that’s exactly what I need! I can create the 3D texture in the following way:
tex = Texture('my3dTexture')
for zi in range(texDepth):
# Create the slices in some way here
p = blahblahblah
# Give the slice to the texture
tex.load(p, zi, 0)
The woodgrain example saves the 3d texture to a file in the disk, so that later on it can be loaded with loader.load3DTexture(). I was wondering if I can omit this saving step, and once I’ve created all the texture slices, send “tex” directly to the fragment shader as a sampler3D.
Panda will reload the texture automatically if you change the pixels, but we don’t provide support for a partial update only with glTexSubImage(). For most texture changes, the bandwidth requirements are minimal anyway; though it’s true this may not be true if you have a large 3-D texture. It may be possible to force a call to glTexSubImage() via an OpenGL callback, though this would be complicated. I recommend just using the full-update that Panda provides, until it proves to be a bottleneck.