PDA

View Full Version : Multiply pixel components on front buffer



EricP
01-31-2003, 06:01 AM
Hi all,
let's see what i want to do :
I want to apply a color mask texture on front buffer. This is not a pixel visibility mask, but a pixel's component one...
For example, if my masking texture is a red one, all pixels which contain no red value on front buffer need to be discard :

current pixel on front buffer : (0,G,B)
current pixel on the masking texture : (R,0,0)

So (0,G,B) * (R,0,0) = (0,0,0)

For the moment, i do this using PBuffer and multiTexturing: i render the scene into the PBuffer, then apply the masking texture on it using multitexturing, which authorize multiplication of pixel components.

But now, i would like to achieve this WITHOUT PBuffering... the main idea is to render a full screen rectangle after the standard scene render process, and to let my Geforce4 multiply pixel components.

Have u got any idea to achieve that ? maybe using TexEnvMap (GL_MODULATE property) or Stencil buffer ?

Another thing, i don't want to use pixel and vertex shaders...

Thank you for your help !

ScottManDeath
01-31-2003, 06:05 AM
Originally posted by EricP:
[B]
current pixel on front buffer : (0,G,B)
current pixel on the masking texture : (R,0,0)

So (0,G,B) * (R,0,0) = (0,0,0)

[B]

Hi

blending should do it:

glBlendFunc(GL_ZERO,GL_SRC_COLOR);


blending:

pixelcolor = source* source_factor + destination* destination_factor;

you set source_factor to GL_ZERO and destination_factor to GL_SRC_COLOR which yields :

pixelcolor = framebuffer *red_mask_texture;

Bye
ScottManDeath


[This message has been edited by ScottManDeath (edited 01-31-2003).]