Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Blacked out texture

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2006
    Posts
    6

    Blacked out texture

    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:

    Code :
      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]));
        }
      }

  2. #2
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    3,032

    Re: Blacked out texture

    where's your glbindtexture?
    Knackered

  3. #3
    Member Regular Contributor
    Join Date
    Aug 2003
    Location
    France
    Posts
    299

    Re: Blacked out texture

    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.

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: Blacked out texture

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •