|
|
Question about texture using glsl
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: Question about texture using glsl - comp.graphics.api.opengl ...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 ... GLSL, fragment shader, shadow2D and texture unit - comp.graphics ...GLSL, fragment shader, shadow2D and texture unit. ... OT: GeForce FX OpenGL Shading language ... Post Question Groups ... >> texture, are you using the same number of ... GLSL - screen coordinate & texture width - comp.graphics.api ...Hi, I have 2 questions about GLSL fragment shaders: - How can I get the x,y position ... around vector using GLSL - comp.graphics.api.opengl ..... about texture using glsl ... 3D Texture Constraints - comp.graphics.api.openglQuestion about texture using glsl - comp.graphics.api.opengl ... 3D Texture Constraints - comp.graphics.api.opengl Question about texture using glsl - comp.graphics.api ... number of texture units on GeForce 6800 - comp.graphics.api.opengl ...Question about texture using glsl - comp.graphics.api.opengl ... number of texture units on GeForce 6800 - comp.graphics.api.opengl ... GLSL, fragment shader, shadow2D and ... rotate vector around vector using GLSL - comp.graphics.api.opengl ...Question about texture using glsl - comp.graphics.api.opengl ... rotate vector around vector using GLSL - comp.graphics.api.opengl ... Question about texture using glsl ... Projection-state of gl_Vertex in GLSL - comp.graphics.api.opengl ...Hi I'm working on a small vertex shader using GLSL for ... than gl_Vertex.y Answering your next question (next ... > If you change your mind about using textures, have a look at ... Newbie : Loading Textures using Cg - comp.graphics.api.opengl ...... comp.graphics.api.opengl However, I introduced Cg recently, and ... Newbie question about rotate a picture using OpenGL - comp ... ... Question about texture using glsl ... How does a single GLSL shader use a texture unit that can be 2D ...Hello NG, I'm using both 2D and 3D textures in a single texture ... Post Question ... How does a single GLSL shader use a texture unit that can be ... Raw 3D texture - comp.graphics.api.openglQuestion about texture using glsl - comp.graphics.api.opengl ... Raw 3D texture - comp.graphics.api.opengl Question about texture using glsl - comp.graphics.api.opengl ... Question about texture using glsl - comp.graphics.api.opengl ...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 ... opengl es - Projective Texture Mapping using GLSL through WebGL ...I want to project a texture on to a wall or any object. I modified this tutorial's shaders as follows based on this Cg projective texture mapping tutorial (ctrl-f "9 ... 7/26/2012 3:06:59 PM
|
|
|
|
|
|
|
|
|