View Full Version : Blacked out texture

02-03-2006, 04:45 AM
hi all.

I'm sure this is probably just the result of some boneheaded mistake on my part, so hopefully somebody can recognize this problem and tell me what i've done wrong...

I have a working raytracer for volume rendering (in large part due to help from these forums; so thanks for that...). The project now, however, is to change my file loader so it understands some different volume files we have laying around.

I've loaded in the data, and verified, immediately preceding my glTexImage() call, that it does in fact contain nonzero data. For some reason, however, when i load the texture up, it is nothing but zeros. My shader and everything else is unchanged; the only alteration from my last (very nicely) working version was the file loader and texture initialization. It's java, but it should be obvious what lines do what. Here is the code that creates the texture:

private void initializeIntensityVolume(VolumeData vData,GL gl) {

int[] texDim=NPOT_VOLUME_TEXTURE?vData.dim:vData.paddedD im;
gl.glTexImage3D(GL.GL_TEXTURE_3D,0,GL.GL_INTENSITY ,texDim[X],texDim[Y],texDim[Z],0,
GL.GL_UNSIGNED_BYTE,ByteBuffer.wrap(new byte[texDim[X]*texDim[Y]*texDim[Z]]));
for (int i=0; i<vData.dim[Z]; i++) {
gl.glTexSubImage3D(GL.GL_TEXTURE_3D,0,0,0,i,vData. dim[X],vData.dim[Y],1,
vData.greyscaleData.position(vData.greyscaleData.p osition()+

02-03-2006, 05:00 AM
where's your glbindtexture?

02-03-2006, 05:24 AM
Not sure if you don't need to glEnable(GL_TEXTURE_3D) too.
You could also check that you're on the correct tex unit.

02-03-2006, 05:59 AM
OpenGL's minification filter is using mipmaps. You must set the TexParameters if you only load level 0.
Why do you use GL_INTENSITY as internalFormat when loading from luminance data? Luminance does just fine for 3D greyscale data.
Also remember the pixel unpack alignment defaults to 4. For NPOT and byte data 1 would be better.
Looks like your algorithm loads the texture twice, during glTexImage from the "new" buffer and then as slices again.
The initial glTexImage call should use NULL as source pointer in that case.
You can delete the new buffer immediately afterwards if you don't use it for something else.