GLSL value halfed


im having problem with my GLSL. so i kept my data in the openGL side by using unsigned char*. its basically an 8 bit data so it will fit the ALPHA8 or GL_RED. i send the data GPU memory by using this:

glTexImage3D(GL_TEXTURE_3D, 0, GL_ALPHA8, textureWidth, textureHeight,
textureDepth, 0, GL_ALPHA, GL_UNSIGNED_BYTE, index3D);

i also has tested using GL_RED instead of GL_ALPHA8. on the GLSL side, i call the value by using this

currIndex = vCurrIndex.a;

or .r if i kept it as RED value. however the data value seems to be halfed. When I check it using this:

if ( currIndex < 0.5) {
color = vec4(1.0, 0.0, 1.0, 1.0); // pink
} else color = vec4(0.0, 1.0, 0.0, 1.0); // green

it all turned up green. but if i put a higher treshold, let say 0.6, there are a few part is pink.

I already check the data before it was sent to the GPU, and its a correct data between 0-255 (converted to unsigned char). Any idea why its halfed? Did i do something wrong back there?

thanks in advance

however the data value seems to be halfed.

No, the data all seems to be between 0.5 and 1.0. That’s not halved. Or rather, it’s not just halved.

Did you turn off texture filtering?

im sorry what is texture filtering? how do i know i turned it on/off?

yes the data is 0.5 and 1.0. and i already checked the data before i sent it to the GPU and its ranged from 0-1.0

any idea why?

Texture Filtering.

ah okay im familiar with that, but thats not the problem imo since i do it with other texture and it seems ok.

the data that i sent is pretty normally distributed from 0-255(0-1). when i render the image, it looks like it spread from 128-255(0.5-1.0).

im afraid that this got something to do with me keeping it as an 8 bit values instead of 3x8 bit value. i already test GL_ALPHA(later called index.a) and GL_RED(index.r) but still no luck.

any idea why?

thanks in advance

EDIT: here is the whole code if it helps

here is the result

i think its pretty easy to understand. any idea why?

thanks in advance

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.