PDA

View Full Version : GLSL value halfed



jos_t_tarigan
09-06-2010, 02:49 PM
hi,

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

Alfonse Reinheart
09-06-2010, 03:46 PM
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?

jos_t_tarigan
09-06-2010, 03:55 PM
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?

Alfonse Reinheart
09-06-2010, 04:03 PM
Texture Filtering (http://www.opengl.org/wiki/Texture#Filtering).

jos_t_tarigan
09-06-2010, 04:12 PM
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 (http://pastebin.com/NCpEaZH9) is the whole code if it helps


here (http://www.flickr.com/photos/42848335@N05/4965228937/) is the result

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

thanks in advance