Results 1 to 6 of 6

Thread: Destination alpha test

  1. #1
    Senior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    London, England
    Posts
    160

    Destination alpha test

    I posted this in the nehe forum but no-one knew. Do you have any ideas?

    I have (after a few passes) a screen consisting of shades of gray. Each pixel has an rgba color of k, k, k, k (0<=k<=1). Now, I want to draw on the screen another texture, but only on the parts of the screen of color (1, 1, 1, 1), and not on the rest. Is there any way to do this in (preferably unextended) openGL?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: Destination alpha test

    Hi

    You could create an alpha texture from the screen with glCopyTexImage2D (or glCopyTexSubImage2D for better performance) and use source alpha test. This requires multitexturing, but thats supported on nearly every card.

    I don't know a way to do this with unextended opengl.

    A completely different approach would be to use the stencil buffer. If thats usable for you depends on the way you generate your alpha values.

    Hope that helps
    Overmind

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2001
    Posts
    104

    Re: Destination alpha test

    A little bit sick way to do, but it should work, you've to do this depending on the amount of colorbufferbits with lower or higher alpha value, let's say we'd a 24 bit colorbuffer:
    -Blend a black polygon over the screen with alpha of 254/255. All RGBs which were lower than 255 are 0 then, all which were 255 are 1. Draw multiplicative now a white one again over the whole screen. The area which was
    1,1,1,1 before should be white now, the rest 0,0,0,0. Now paint what you wanted to do multiplicative as well and it will just appear in the area which was 1,1,1,1.

    Michael

  4. #4
    Senior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    London, England
    Posts
    160

    Re: Destination alpha test

    Thanks BlackJack.

    What blending factors should I use?

  5. #5
    JasonM [ATI]
    Guest

    Re: Destination alpha test

    How are you generating the grayscale in the dest alpha in the first place? Could this be done in the stencil buffer instead? If so, the masking you want on a subsequent pass would be more straightforward than masking based on dest alpha.

    -Jason

  6. #6
    Senior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    London, England
    Posts
    160

    Re: Destination alpha test

    I draw my scene with two grayscale textures (auto texcoord generation), and use additive blending. If the result is 1.0f, I want to draw in a third texture. Other places, the scene can be left as it is or cleared. I cannot use multitexture since texgen will not work independently for both texture units on a TNT2.

    Thanks

Similar Threads

  1. OpenGL ES 2.0 Enabling Alpha Buffers for Destination Blending
    By hhenderson in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-25-2015, 05:08 PM
  2. Antialiased lines with correct destination alpha
    By surfdabbler in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-11-2010, 04:33 PM
  3. alpha blending without modifying destination alpha
    By GordAllott in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-21-2009, 04:15 AM
  4. Can Alpha Test work the same way as Depth Test?
    By Rong Yao in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 05-13-2004, 02:40 PM
  5. ARB_texture_env_combine and destination alpha
    By JanHH in forum OpenGL: Advanced Coding
    Replies: 14
    Last Post: 12-29-2003, 08:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean