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 9 of 9

Thread: 3d texture problem with (unsigned) short data type

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2006
    Location
    Slovakia
    Posts
    3

    3d texture problem with (unsigned) short data type

    dear friends,
    i have this small problem when creating and generating 3d texture.

    Code :
    first i have an array for my data:
    static unsigned short array[24][24][24][3];
     
    then i fill it with some random numbers as colors:
    for(int x=0; x<24; x++)
    				for(int y=0; y<24; y++)
    					for(int z=0;z<24;z++)
    					{
    						array[x][y][z][0] = rand()255;
    						array[x][y][z][1] = rand()255;
    						array[x][y][z][2] = rand()255;
     
    					}
    then i generate it & bind it, set neccessary
    parameters, i am not writing it here, cause i think thats not the point of my problem.
     
    after that i use 
    glTexImage3D for creating it:
    glTexImage3D(GL_TEXTURE_3D, 0,GL_RGB8 , 24,24,24,
    						0,GL_RGB , GL_UNSIGNED_SHORT, &amp;array);
     
    and finnaly map it on to a quad (i mean a rectangle although it is a 3d texture :)
    so the problem is:
    when i use GL_UNSIGNED_BYTE as a parameter it is ok.
    i can see nice blue,red and so on rectangle.
    but when i use GL_UNSIGNED_SHORT i can see only a black screen = nothing

    CAN anybody tells me where is the problem? what is wrong? should any parameter should be changed?

    thanks in advance.

    joe

  2. #2
    Intern Contributor
    Join Date
    Oct 2003
    Posts
    68

    Re: 3d texture problem with (unsigned) short data type

    try random #s up to 65535 instead of 255?

  3. #3
    Intern Newbie
    Join Date
    Mar 2005
    Location
    A Coruña (Spain)
    Posts
    44

    Re: 3d texture problem with (unsigned) short data type

    24x24x24 ? The texture size must be a power of two, as it says the glTexImage3D specification.

    Try a 16x16x16 or a 32x32x32 size.

    Is very strange that this works with GL_UNSIGNED_BYTE, Do you really see something with this internal format?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: 3d texture problem with (unsigned) short data type

    Originally posted by API:
    24x24x24 ? The texture size must be a power of two, as it says the glTexImage3D specification.
    If ARB_texture_non_power_of_two extension or OpenGL 2.0 is supported, the power of two limitation does not apply to any texture target.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    924

    Re: 3d texture problem with (unsigned) short data type

    The ushort values are converted into (0.0-1.0) float range by division by (2^16 − 1) so value of 255 will be stored inside the texture as 0 or 1 from the 0-255 scale.

  6. #6
    Intern Newbie
    Join Date
    Mar 2005
    Location
    A Coruña (Spain)
    Posts
    44

    Re: 3d texture problem with (unsigned) short data type

    If ARB_texture_non_power_of_two extension or OpenGL 2.0 is supported, the power of two limitation does not apply to any texture target.
    You are right, but as he doesn't say if this extension is supported I just wondering his problem ( and is common to me to not suppose this extension, as my card doesn't support it directly )

    Well, jozko_sk, at this moment I(we) don't know what is your problem, can you give us more information?:
    * More code
    * Card
    * Drivers
    * Extensions used

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: 3d texture problem with (unsigned) short data type

    Originally posted by API:
    If ARB_texture_non_power_of_two extension or OpenGL 2.0 is supported, the power of two limitation does not apply to any texture target.
    You are right, but as he doesn't say if this extension is supported I just wondering his problem ( and is common to me to not suppose this extension, as my card doesn't support it directly )
    He said the texture worked when he used GL_UNSIGNED_BYTE.

    Anyway, the problem is most likely what 3B and Komat said; the range of unsigned short values is [0, 65535], not [0, 255].

  8. #8
    Junior Member Newbie
    Join Date
    Oct 2006
    Location
    Slovakia
    Posts
    3

    Re: 3d texture problem with (unsigned) short data type

    hi guys,
    its me, jozko.
    thanks a lot for all your information.
    the problem was in generation of colors, which should be 65535 and not 255.
    and with texture array, you are right it should be power of 2 so not 24, but a really can see an image , i can send it to you .
    but i think it is because my card support non power of two.

    but another question:
    i have an array for example 64x64x64 for my 3d texture in unsigned short.
    then i put some data into the array >
    Code :
    unsigned short array (64x64x64); //simplified :)
    for (int i=0; i<64; i++)
    {
       //but my temp data is only 4096 , 12bit
       array = tempdata;
       array += 64x64 ;
    }
    then i use the array as a data for 3d texture, but i am using the unsigned_short parameter.
    i cannot see anything again.
    i think i must stretch the array , so it is not from 0 to 4096 but to 65535.
    any ideas?

    thanks a lot.

  9. #9
    Intern Newbie
    Join Date
    Mar 2005
    Location
    A Coruña (Spain)
    Posts
    44

    Re: 3d texture problem with (unsigned) short data type

    Simplify, before showing a random texture make three experiments, try to show a red, green and blue texture. This will show you what range do you really need.

Posting Permissions

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