PDA

View Full Version : 3d texture problem with (unsigned) short data type



jozko_sk
10-12-2006, 10:45 AM
dear friends,
i have this small problem when creating and generating 3d texture.


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 :)

3B
10-12-2006, 02:14 PM
try random #s up to 65535 instead of 255?

API
10-13-2006, 01:42 AM
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?

Komat
10-13-2006, 02:21 AM
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.

Komat
10-13-2006, 02:32 AM
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.

API
10-13-2006, 05:51 AM
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

Bob
10-13-2006, 08:00 AM
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].

jozko_sk
10-15-2006, 06:18 AM
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 >

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.

API
10-15-2006, 11:37 PM
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.