Results 1 to 5 of 5

Thread: Sampling an alpha texture with texture2D

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    23

    Sampling an alpha texture with texture2D

    I want to use an 8-bit texture as a mask. I upload the texture in GL_ALPHA format. How should I sample it? texture2D() returns a vec4 - does every component of the vec4 contain the sampled value, or only the last (.a) component?

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Sampling an alpha texture with texture2D

    Only the alpha component. This is how the texture formats get expanded to vec4:
    Code :
    GL_ALPHA            (0, 0, 0, A)                    
    GL_RGB              (R, G, B, 1)
    GL_RGBA             (R, G, B, A)
    GL_LUMINANCE        (L, L, L, 1)
    GL_LUMINANCE_ALPHA  (L, L, L, A)
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    23

    Re: Sampling an alpha texture with texture2D

    Just what I was looking for, thanks.

    PS: Is this documented in the spec at all? I had a look but couldn't find it?

  4. #4
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Sampling an alpha texture with texture2D

    Yes, it's table 3.12 in the full spec.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  5. #5
    Junior Member
    Join Date
    May 2008
    Posts
    23

    Re: Sampling an alpha texture with texture2D

    Full spec you say....

    I've been using the difference spec for all this time! Thank you, I think you've probably saved me from months more of frustration. I no longer have to flick between the desktop OpenGL 2.0 spec and the ES 2.0 diff spec!

Similar Threads

  1. Problem with render to texture using pbuffer and alpha
    By PKH68 in forum OpenGL ES 1.X - fixed function hardware
    Replies: 2
    Last Post: 01-07-2009, 01:44 AM
  2. Composing Alpha only texture images
    By iswhite in forum OpenGL ES general technical discussions
    Replies: 4
    Last Post: 05-15-2008, 10:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •