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: Fragment thresholding

  1. #1
    Advanced Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    764

    Fragment thresholding

    How can I implement texture thresholding in a nice way?

    I have a B/W texture (read from the framebuffer with glCopyTexSubImage) that I would like to write back to the framebuffer using thresholding.

    I would like to be able to implement:

    fragment >= threshold -> color 1 (white)
    fragment < threshold -> color 2 (black or background)

    I think one way would be to use alpha testing, but I don't have the alpha channel.

    [Edit:] Can I copy from the color buffer (e.g. the red channel) to the texture alpha channel by using the color matrix extension (I know I can, but is it widely supported in hardware?).

    Also, I would like to avoid fragment programs and register combiners. Multitexturing is OK though.


    [This message has been edited by marcus256 (edited 04-15-2003).]

  2. #2
    Email address no longer exists Frequent Contributor
    Join Date
    Dec 2002
    Location
    Espoo, Finland
    Posts
    599

    Re: Fragment thresholding

    Hi,

    Can you use the arb dot3 extension? Cause then you could just calculate the dot product between the color and (1, 0, 0), put that to alpha and use the alpha test.

    -Ilkka

  3. #3
    Advanced Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    764

    Re: Fragment thresholding

    Originally posted by JustHanging:
    Hi,

    Can you use the arb dot3 extension? Cause then you could just calculate the dot product between the color and (1, 0, 0), put that to alpha and use the alpha test.

    -Ilkka
    Thanks!!!!

    Yes, I'm requiring OpenGL 1.3 already (it has GL_DOT3_RGBA), so no problem.

    I actually did not fully understand the GL 1.3 spec w.r.t. GL_DOT3_RGBA. After reading it again I see what you mean.

    I will try it.

Posting Permissions

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