Question about texture using glsl

  • Follow


hi, all. i have a quesion about glsl. i have got a grayscale medical
image whose pixel format is unsigned short. now i want to access the
pixel value in the frag shader. but using the follow code snippet:

uniform sampler2D myTexture;
varying vec2 vTexCoord;
vec4 color = texture2D(myTexture, vTexCoord);

i found that the value is clamped to 0.0 ~ 1.0(because of the
sampler), not from 0 ~65535, which mean a huge information lost.....

Is there any method that i can get the exact intensity of the pixel?

and i also heard that there is a opengl extension called
"GL_LUMINANCE_INTEGER_EXT", now i try to adjust my code to:
	glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16UI_EXT, pack->width,
pack->height, 0, GL_LUMINANCE_INTEGER_EXT, GL_UNSIGNED_SHORT, pack-
>texture);

what should i do next?

thx in advance and any suggestion would be apprciated~~ ^  ^

 
elvis

0
Reply elvis 9/27/2008 9:59:17 AM

"elvis" <yejun.elvis@gmail.com> wrote in message 
news:43145d22-8efe-4000-a2ef-df7db6300d60@a19g2000pra.googlegroups.com...
> uniform sampler2D myTexture;
> varying vec2 vTexCoord;
> vec4 color = texture2D(myTexture, vTexCoord);
>
> i found that the value is clamped to 0.0 ~ 1.0(because of the
> sampler), not from 0 ~65535, which mean a huge information lost.....

The 16 bit unsigned format you use is normalized. The sampler returns vec4, 
which is floating-point. You're doing fine.


(normalized means that the values are between 0.0 and 1.0, just stored using 
fixed precision.. 65535 == 1.0)


0
Reply t0rakka 9/27/2008 10:52:43 AM


On Sep 27, 11:59=A0am, elvis <yejun.el...@gmail.com> wrote:
>
> what should i do next?
>

Use a for() loop to change the texture to something more suitable
before you upload it.


--
<\___/>
/ O O \
\_____/  FTB.

http://www.topaz3d.com/  - New 3D editor!
0
Reply fungus 9/27/2008 12:21:45 PM

2 Replies
324 Views

(page loaded in 0.075 seconds)

Similiar Articles:













7/26/2012 3:06:59 PM


Reply: