Alpha Blending

Hello,

I'm looking for a way to modify the pixel values (RGBA) across a
particular texture on the fly (i.e., without re-creating a new
texture via "Screen('MakeTexture')"). I don't want to modulate the
whole texture (which is an image), only particular parts of it, by
very simple operations like color inversion or changes to an alpha
value. Is there any way to index the pixels of a texture? Or any
other way to do something along these lines?

Thanks,

Mark
Tons, but which is the most effective/efficient
depends on your specific needs and capabilities
of your GPU.

e.g., as textures can be treated also as offscreen
windows, you can use the normal Screen drawing
commands to "overdraw" parts of a texture to
modify it, etc.

For a really low-speed approach
you could:

tex = Screen('MakeTexture',...);
Screen('GetImage', tex, ....) to get back portions
of the texture back into a Matlab matrix.
Screen('PutImage', tex, ....); to put manipulated
matlab matrix back into the texture.

If you need to work a lot with offscreen windows,
look at help PsychImaging for the section about...
PsychImaging('AddTask', 'General', 'UseFastOffscreenWindows');...
on how to enable fast offscreen window support on
modern GPUs.

Alpha-Blending allows for lots of neat tricks, and
the Screen('Blendfunction') function also allows to
optionally set color write-masks, e.g., to restrict
drawing commands to only "overdraw" selected
color channels or the alpha channel.

The optional 'modulateColor' argument to Screen
Drawtexture may allow to modulate some aspects
of drawing on the fly.

Then there is support for "procedural textures", where
you can manipulate or redefine the content of a
texture during drawing, e.g., apply filters, color
transforms etc., or even create a texture on the fly
from a set of parameters during drawing.

E.g. ExpandingRingsDemo, MandelbrotDemo,
ImageWarpingDemo, ImagingVideoCaptureDemo,
GazeContingentDemo, GarboriumDemo,
ProceduralGaborDemo,...

And then there is Screen('TransformTexture')
for application of complex image processing operators
to textures...

I guess you need to be much more specific.
-mario

--- In psychtoolbox@yahoogroups.com, Mark Lescroart <lescroar@...> wrote:
>
> Hello,
>
> I'm looking for a way to modify the pixel values (RGBA) across a
> particular texture on the fly (i.e., without re-creating a new
> texture via "Screen('MakeTexture')"). I don't want to modulate the
> whole texture (which is an image), only particular parts of it, by
> very simple operations like color inversion or changes to an alpha
> value. Is there any way to index the pixels of a texture? Or any
> other way to do something along these lines?
>
> Thanks,
>
> Mark
>
Screen('Blendfunction', window, GL_ONE, GL_ZERO);

--- In psychtoolbox@yahoogroups.com, "ustcbm" <ustcbm@...> wrote:
>
> Hi Mario,
>
> In my code, I only hope to use alpha blending in one section. And in
> the next section, I don't want to use alpha blending. Can you
> introduce how to stop the alpha blending? Thanks!
>
> Min
>
> --- In psychtoolbox@yahoogroups.com, "Mario Kleiner"
> <mario.kleiner@> wrote:
> >
> > Tons, but which is the most effective/efficient
> > depends on your specific needs and capabilities
> > of your GPU.
> >
> > e.g., as textures can be treated also as offscreen
> > windows, you can use the normal Screen drawing
> > commands to "overdraw" parts of a texture to
> > modify it, etc.
> >
> > For a really low-speed approach
> > you could:
> >
> > tex = Screen('MakeTexture',...);
> > Screen('GetImage', tex, ....) to get back portions
> > of the texture back into a Matlab matrix.
> > Screen('PutImage', tex, ....); to put manipulated
> > matlab matrix back into the texture.
> >
> > If you need to work a lot with offscreen windows,
> > look at help PsychImaging for the section about...
> > PsychImaging('AddTask', 'General', 'UseFastOffscreenWindows');...
> > on how to enable fast offscreen window support on
> > modern GPUs.
> >
> > Alpha-Blending allows for lots of neat tricks, and
> > the Screen('Blendfunction') function also allows to
> > optionally set color write-masks, e.g., to restrict
> > drawing commands to only "overdraw" selected
> > color channels or the alpha channel.
> >
> > The optional 'modulateColor' argument to Screen
> > Drawtexture may allow to modulate some aspects
> > of drawing on the fly.
> >
> > Then there is support for "procedural textures", where
> > you can manipulate or redefine the content of a
> > texture during drawing, e.g., apply filters, color
> > transforms etc., or even create a texture on the fly
> > from a set of parameters during drawing.
> >
> > E.g. ExpandingRingsDemo, MandelbrotDemo,
> > ImageWarpingDemo, ImagingVideoCaptureDemo,
> > GazeContingentDemo, GarboriumDemo,
> > ProceduralGaborDemo,...
> >
> > And then there is Screen('TransformTexture')
> > for application of complex image processing operators
> > to textures...
> >
> > I guess you need to be much more specific.
> > -mario
> >
> > --- In psychtoolbox@yahoogroups.com, Mark Lescroart <lescroar@> wrote:
> > >
> > > Hello,
> > >
> > > I'm looking for a way to modify the pixel values (RGBA) across a
> > > particular texture on the fly (i.e., without re-creating a new
> > > texture via "Screen('MakeTexture')"). I don't want to modulate the
> > > whole texture (which is an image), only particular parts of it, by
> > > very simple operations like color inversion or changes to an alpha
> > > value. Is there any way to index the pixels of a texture? Or any
> > > other way to do something along these lines?
> > >
> > > Thanks,
> > >
> > > Mark
> > >
> >
>