3D Textures [SOLVED]

Hi all!

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)

I don’t know much about it but have you read this: panda3d.org/manual/index.php/3-D_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.

Thanks! I’ll take a look to it…

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:

http://gpwiki.org/index.php/OpenGL_3D_Textures

(In the section building a simple 3D texture)

Cheers!

I’ve been reading more carefully http://www.panda3d.org/manual/index.php/3-D_Textures and http://www.panda3d.org/manual/index.php/Woodgrain_Example

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.

Will this be possible?

Thanks!

Certainly. Once you have created the 3-D Texture, you can do whatever you like with it, including render it with a shader.

David

Thanks for the answer David!

I’ll implement this 3-D texture thing in these days and see what can I come up with.

One last thing, for implementing this technique (octree textures, http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter37.html), I need to be able to modify the 3-D texture once it has been uploaded to the GPU, as this paper’s quote states:

So I was wondering if this can be done with Panda. I mean, is it possible to partially update a 3D-texture using the glTexSubImage3D API call?

How does Panda manages this?

Once again, thank you very much!

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.

David

Great! Thanks for your advice David!

I’ll try to implement all this stuff in this week, and see how it turns out. I hope it all goes well without using partial updates.

Cheers!