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).]

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

Originally posted by JustHanging:
[b]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[/b]

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.