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) {
makeActive(gl);
vData.greyscaleData.rewind();
int[] texDim=NPOT_VOLUME_TEXTURE?vData.dim:vData.paddedDim;
gl.glTexImage3D(GL.GL_TEXTURE_3D,0,GL.GL_INTENSITY,texDim[X],texDim[Y],texDim[Z],0,
GL.GL_LUMINANCE,
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,
GL.GL_LUMINANCE,
GL.GL_UNSIGNED_BYTE,vData.greyscaleData);
vData.greyscaleData.position(vData.greyscaleData.position()+
(vData.dim[X]*vData.dim[Y]));
}
}