python - Psychopy:混合模式添加对比度不良

标签 python opengl pyglet psychopy

我在 Psychopy 中使用 blendMode="add" - 幸运的是,GratingStim 对比度仅在窗口中未绘制文本时才有效。一旦绘制文本 - GatingStims 对比度看起来就好像从中减去了 1(看一下屏幕截图)。我在使用 avg BlendMode 时没有遇到此问题,但我确实需要 blendMode="add"

这是绘制文本之前 GatingStim 的外观:
enter image description here
这是绘制一些文本后的样子:
enter image description here

将文本绘制到窗口后,任何后续的 GatingStim 都会像这样呈现对比度。只有打开另一个窗 Eloquent 有帮助。
我想这可以通过向 pyglet 注入(inject)一些着色器来解决,但我不知道该怎么做( related issue on github )。

下面的代码重现了这个问题:

from psychopy import visual, event, core

win = visual.Window(monitor='testMonitor', useFBO=True,
    blendMode='add', units='deg')

g = visual.GratingStim(win, tex='sin', mask='gauss', size=4.5, pos=(0,6))
t = visual.TextStim(win=win, text='Hello blendMode="add"!')

draw_order = [[g], [g, t], [g, t]]
for draw_now in draw_order:
    for stim in draw_now:
        stim.draw()
    win.flip()
    event.waitKeys()

core.quit()

我使用的是 Windows - 我在 Windows 7 和 8 上都遇到此问题。

最佳答案

好吧,我的猜测是 pyglet 文本渲染器正在执行一些更改混合模式规则的代码,以便在绘制文本时其左侧处于错误状态。目前正在做

win.blendMode = 'add'

绘制文本刺激后解决了我的问题

关于python - Psychopy:混合模式添加对比度不良,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32184164/

相关文章:

python - Pyglet游戏 Action 落后

python - pyglet 显示的 numpy 数组不正确

python 类方法 get_by_user 返回 None

python - 为什么 20130708 < ""在 Python 中返回 true?

python - 使用 python imaplib 到 "delete"来自 Gmail 的电子邮件?

c++ - CUDA/OpenGL 互操作 : Writing to surface object does not erase previous contents

c++ - OpenGL MRT glDrawBuffers() 参数编号和行为

c++ - 在多个函数中使用全局 glfw 窗口

python - 访问下一个同级的文本

python - 在鼠标拖动 Pyglet 周围绘制一个矩形