Blend function - please help (MATLAB 2020b)

9 次查看(过去 30 天)
Hi,
Could someone clarify to me what the function below is needed for when setting up a script to run a stroop task?
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
Many thanks in advance.

回答(1 个)

Walter Roberson
Walter Roberson 2020-10-29
"The most common alpha-blending factors are sourceFactorNew = GL_SRC_ALPHA and destinationFactorNew = GL_ONE_MINUS_SRC_ALPHA They are needed for proper anti-aliasing (smoothing) by Screen(‘DrawLines’), Screen(‘DrawDots’) and for drawing masked stimuli with the Screen(‘DrawTexture’) command."
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
is telling Psychtoolbox to use compute:
information to store = new screen data * alpha + old screen data * (1-alpha)
so for example if alpha were .8 then it would be new*0.8 + old*0.2
  2 个评论
Thomas Pace
Thomas Pace 2021-2-16
So if, for example, I wanted to present 4 textures using Screen('DrawTexture') in the same location, and have them all end up with equal alpha, what is the formula I would use for dictating each textures globalAlpha values?
For example, if globalAlpha (GA) for the first texture drawn was set at 1, I assumed the second texture drawn on top would need to be presented with GA of 0.5. But then what would the third texture drawn GA be such that all 3 have equally presented energy? Is there a formula for this?
Walter Roberson
Walter Roberson 2021-2-16
编辑:Walter Roberson 2021-2-16
syms I1 I2 I3 I4 a1 a2 a3
t1 = I1*(1-a1) + I2*a1
t1 = 
t2 = t1*(1-a2) + I3*a2
t2 = 
t3 = t2*(1-a3) + I4*a3
t3 = 
t4 = collect(expand(t3),[I1,I2,I3,I4])
t4 = 
c1 = coeffs(t4,I1)
c1 = 
c2 = coeffs(t4,I2)
c2 = 
c3 = coeffs(t4,I3)
c3 = 
c4 = coeffs(t4,I4)
c4 = 
sol = solve([c1(end),c2(end),c3(end)]==1/4,[a1,a2,a3])
sol = struct with fields:
a1: [1×1 sym] a2: [1×1 sym] a3: [1×1 sym]
sol.a1
ans = 
sol.a2
ans = 
sol.a3
ans = 
%cross-check
subs([c1(end),c2(end),c3(end),c4(end)], sol)
ans = 
So use alpha = 1/2 for the first overlay, alpha = 1/3 for the second overlay, alpha = 1/4 for the third overlay.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by