Screen(‘BlendFunction’) applying different versions to different textures on the same screen

Hi, It seems like I need to use
Screen(‘BlendFunction’, win, ‘GL_SRC_ALPHA’, ‘GL_ONE_MINUS_SRC_ALPHA’) to create my grating properly in my code. I also want to use CreateProceduralGasussBlob function superimposed to my grating. However it seems like CreateProceduralGasussBlob requires me to use
Screen(‘BlendFunction’, win, GL_ONE, GL_ONE). Otherwise it doesn’t look like a Gaussian blob. Is there a way that I can use different parameters of Screen(‘BlendFunction’) for different textures at the same time on the same screen?
Thank you for the help!

It should work fine (I think) to call Screen(‘BlendFunction’,…) right before each place where you need to change it, give that a try.

Cheers,
Dee

1 Like

Yep, we do it all the time for displays that incorporate anti-aliased dots & procedural gabors.

There is some overhead in applying the Screen(‘BlendFunction’…) switch, so you’d just want to be sure to group all of your procedural drawing together, switch to GL_ONE, draw all your blobs, switch back to ‘alpha-one-minus-alpha’ — as opposed to toggling back & forth in a loop “1 grating, 1 dot, 1 grating, 1 dot, …”

e.g.

% must change blend function for procedural gabor rendering
% ...only one BlendFunction to set, not separate for each stereobuffer.
[prevSrcRect, prevDestRect] = Screen('BlendFunction', p.trial.display.ptr, 'GL_ONE', 'GL_ONE');
drawTheGabors(p, sn);
% reset previous blend functions
Screen('BlendFunction', p.trial.display.ptr, prevSrcRect, prevDestRect);

-Thad.

2 Likes

Thank you for your response. Thad. This is really helpful!