I’m trying to create a 3D texture procedurally, that later on I can pass to a fragment shader as a sampler3D. I’m trying to create a GPU equivalent of a CPU octree, by using octree textures as described here: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter37.html
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)
afaik a 3d texture is nothing else than a textured cube - which may project its textures on another object
in my project i simply create 6 quads, assign them some textures and create a cube with those.
though i 'm not sure if that’s what you’re talking about… sry.
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')
tex.setup3dTexture()
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.