szamil's picture

3D texture size

Hi again,
I have a problem with 3D texture, I think with its size. I'm creating a cube of 512x512x96x1 voxels and it is displayed correctly with shaders. But when I'm increasing size of this cube it doesn't display at all (black cube). As I calculated it looks like I can only upload about 24MB of 3d texture to the video memory (!?).

I'm working on Win 7 with NVidia FX 1600M. I have to say that some time ago I worked with 512x512x125x2 cube with no problems (but without shaders!).

Thanks for any help!


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
szamil's picture

OK, I think I have solved it.

I have found that the problem is the voxel size. I have been doing 3d texture in ubyte array and passed it as a UnsignedByte array:

byte[] voxels;
...
//texture generation process
...
GL.Ext.TexImage3D(TextureTarget.Texture3D, 0, PixelInternalFormat.Luminance, 
                 w, h, d, 0, PixelFormat.Luminance, <b>PixelType.UnsignedByte</b>, voxels);

But after I'd changed it to float I was able to generate and display 512x512x512x1 float 3d texture.

I'm really not sure why the byte array doesn't work above 512x512x96... Can anyone explain it to me?

szamil's picture

Now I solve it and explained it:

GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
GL.PixelStore(PixelStoreParameter.PackAlignment, 1);

solved the problem of the 3d texture size with uchar. These options are necessary to tell OpenGL to align bytes in memory one by one - like uchars, not like floats.

I think this topic may now be closed.

LikeKT's picture

HI Szamil,

Are you implementing the texture3d together with transfer function for volume or texture3d rendering? I hope to learn how to do it. Do you have internet site with OpenGL codes that I could learn how to do it in OpenTK. Thanks.

szamil's picture

Hi

http://graphicsrunner.blogspot.com/2009/01/volume-rendering-101.html - this should help. I've learn a lot from this blog. This is not exactly for OpenGL but he explains general idea and gives examples. Very useful.

Regards

LikeKT's picture

Yes, I have seen it, I wonder if I need to port it to OpenTK, I may need to learn GLSL, another advance topic for me. :-(

szamil's picture

You may simply use shader from this blog - works fine.
You may also try Render Monkey software to learn GLSL as well as read OpenGL Bible.

Good Luck!