I have a blending question which has been making my head hurt a little, not really done blending before.
What I have is a texture mapped quad which takes up the whole window. I need to draw a smaller quad on top of that texture which takes the exact colour of the texture underneath. Then I remove a channel of colour e.g.
If i understand you correctly, you want to render a quad and where that quad gets rendered the framebuffer is supposed to get subtracted ie. the red channel.
I didn´t test it, but it might be possible to do it this way:
The blending equation is
color = src * srcfactor + dst * dstfactor
Since you only want to read the dst-color, but don´t want to add anything, you need to set srcfactor = 0 (GL_ZERO) and dstfactor = 1 (GL_ONE).
With your writemask set to filter the red channel this should work as expected.
The color and texture of your quad should be unimportant.
That does make sense but doesnt seem to work. After playing in photoshop i wondered if i can repicate what happens there, if i draw a red sqare on the image and then blend using a difference filter, it basically subtracts the redsqare from the image… now doing it in opengl. can i draw a red polygon and in blending subtract that from the underlying texture?
works, but i was hoping to still be able to set alpha values as well… humph… [/b]
That works??? I can´t believe it, because you multiply src and dst with zero, meaning, that you will write black into your framebuffer.
Of course, if you read the image and write it back to the framebuffer, except for the red channel, then you don´t see a difference, because the red channel is already set, and you don´t modify it, so actually you don´t change anything.
What you want to do, is to reset a specific channel to 0. So, if you want to filter out the red channel, you actually want to set the red channel to 0 and leave the rest as is.