Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: how to compose two images according to their zbuffer values?

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    18

    how to compose two images according to their zbuffer values?

    i have got two images's RGB and their zbuffer values with glReadPixel.now i want to compose them together by comparision of zbuffer values. if i do it pixel by pixel, i'm afraid it will cost a lot time. i also want to reach 20 frames per second. who can give some suggestion on it? thanks

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2002
    Location
    Espoo, Finland
    Posts
    599

    Re: how to compose two images according to their zbuffer values?

    Hi, how about

    Code :
    for each pixel
       if z1<z2 then color = color1 else color = color2
    If that's not fast enough, you could try rendering the two images into a texture, storing the depth value in an alpha channel. Then first render the first picture to the screen (if it's not there already) and then the second one on top of it. For the second one use multitexturing and texture_env_combine to place color2 into the rgb channel and depth1(alpha) - depth2 into the alpha channel. Then use alpha test to discard all fragments with alpha>0, meaning that depth2<depth1.

    -Ilkka

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Posts
    531

    Re: how to compose two images according to their zbuffer values?

    Wow, you've just invented the triple post!

    (see other forums)

Posting Permissions

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