PDA

View Full Version : Fragment thresholding



marcus256
04-14-2003, 10:28 PM
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).]

JustHanging
04-15-2003, 01:14 AM
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

marcus256
04-15-2003, 11:54 AM
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.