Image blending

  • Follow


Hi,
    I'd like to blend 2 images together such that I can control how much of
each image is output. However, I need to vary the proportion of each image
that is used throughout the image. For example, the top-left part of the
resultant image might contain contributions from the 2 input images in the
proportion of say 10/90%, whilst the bottom left might contain contributions
in the proportions 50/50%. I'd like to be able to control the per pixel
contribution proporting using a single 8-bit plane, where each value would
define the proportion (unless there's a better way of doing it?).

Is this 'do-able' in OpenGL in a way that might support a decent (say 30f/s)
frame rate?. Also, has anybody any ideas on appropriate/efficient mechanisms
that would provide such behaviour?.

Ta,.
Dave






0
Reply Dave 8/10/2005 3:54:21 PM

Dave Moore wrote:
> Hi,
>     I'd like to blend 2 images together such that I can control how much of
> each image is output. However, I need to vary the proportion of each image
> that is used throughout the image. For example, the top-left part of the
> resultant image might contain contributions from the 2 input images in the
> proportion of say 10/90%, whilst the bottom left might contain contributions
> in the proportions 50/50%. I'd like to be able to control the per pixel
> contribution proporting using a single 8-bit plane, where each value would
> define the proportion (unless there's a better way of doing it?).
> 
> Is this 'do-able' in OpenGL in a way that might support a decent (say 30f/s)
> frame rate?.

Of course!

> Also, has anybody any ideas on appropriate/efficient mechanisms
> that would provide such behaviour?.
> 

You need to but your 8-bit blending info into a texture.
Now you use multitexturing, put your blending info into
texture 1 and image A into texture 2 and draw a quad
using glBlendFunc(GL_SRC_ALPHA, GL_ZERO). This puts
image A in the frame buffer.

Now do the same with image B but change the blending
to (GL_ONE_MINUS_SRC_ALPHA, GL_ONE). This adds image B
to the framebuffer.

If you can use fragment shaders then you can do it all
in one pass.


-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again.  They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful.  But it happens
every day.  I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address

0
Reply fungus 8/10/2005 5:11:12 PM


1 Replies
244 Views

(page loaded in 0.012 seconds)

Similiar Articles:













7/23/2012 1:54:31 AM


Reply: