Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Problem with 16 bit Alpha

This topic is 4942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am writing a medical graphics application for which I need 16 bit grayscale images to be uploaded to OpenGL. For this, I decided to upload the textures as 16 bit alpha (or luminance). The call I'm using to do this is, [MipMapped] Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, 1, loader.ImageWidth, loader.ImageHeight, Gl.GL_ALPHA, Gl.GL_UNSIGNED_SHORT, data); [Non-mipmapped] Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_ALPHA16, loader.ImageWidth, loader.ImageHeight, 0, Gl.GL_ALPHA, Gl.GL_UNSIGNED_SHORT, data); where data is, in both cases, a single dimensional array of ushorts. I'm performing all the fragment operations in a pixel shader (GLSL), which looks like uniform sampler2D Texture0; uniform float invWindowWidth; uniform float intercept; varying vec2 texCoord; void main(void) { float luminance = texture2D(Texture0, texCoord).a; // a linear transfer function that maps the 16 bits of a component // to the 8 bits per component of the framebuffer luminance = (invWindowWidth * luminance) + intercept; gl_FragColor = vec4(luminance, luminance, luminance, 1.0); } I know that the pixel shader works, because I tried putting the high byte in G and the low byte in B and uploading as an RGB texture. But when I change the shader to use the single Alpha component, I get a full white texture. Can someone point me to some code/examples that use 16 bit alpha textures? Any help would be greatly appreciated. Any alternative ways to upload 16 bit per component textures are also welcome, although I would prefer to use an ARB or an EXT extension as opposed to a vendor specific extension. Regards, Ananth B.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!