psychopy.org | Reference | Downloads | Github

Colour problem in 1.90.02

Hi,

There is a problem in v 1.90.? about color. Please have a look at the code below.
This should show a yellowish square on a green background, but we see
blue noise. It happens even with opacity=1.
It becomes fine with blendMode=‘avg’, or useFBO=False.
I wonder if this problem is already investigated.

I’ve found the same problem on Mac (10.13.4) and Win 10. Previous versions seem
to be no problem on the same Mac.

I have several options to avoid it, by using an older version or ‘avg’ mode (with opacity
=1, I suppose it does not have any effect.), but I also wonder what is the actual
impact of useFBO=False.

Best,
Hiroshi

from psychopy import visual, core

win = visual.Window(
    size=[800,800], fullscr=False, screen=0,
    allowGUI=False, allowStencil=False,
    monitor=u'testMonitor', color=[-1,0,-1], colorSpace='rgb',
    blendMode='add', useFBO=True)

polygon = visual.Rect(
    win=win, name='polygon',units='height', 
    width=(0.2,0.2)[0], height=(0.2,0.2)[1],
    ori=0, pos=[0,0],
    lineWidth=0,
    fillColor=[1,-1,-1], fillColorSpace='rgb',
    opacity=0.5)

polygon.draw()
win.flip()
core.wait(1.0)

win.close()
core.quit()

When you include code please add three backticks to make the code readable.

The problem you’re seeing is that you’re using add mode and combining two colors that, when added, come to greater than 1 or less than -1. PsychoPy is letting you know that by giving you something visibly wrong (rather than something with subtle diffs from what you requested)

Dear Jon,

Thank you very much, and sorry about the mess.

I understand the range issue, but I’m afraid I don’t fully understand
how it works with opacity to avoid less than -1.

In the example below, it becomes fine with opacity=0.5.
But isn’t this a bit confusing, or even wrong?

We can’t present full red (or any colour) in the add mode when the
bg is darker than (0,0,0).
And when the bg is (-1,-1,-1), we get pure dark red by adding (1,0,0),
which may be also counterintuitive because we’d expect pink.

Above all, this perfectly works as I expect in previous versions
of PsychoPy, or with the current version (1.90.2) with useFBO=False.

It would be all right if other people understand what it does,
but just in case if someone might have similar problems.

Best regards,
Hiroshi

from psychopy import visual, core

win = visual.Window(
    size=[800,800], fullscr=False, screen=0,
    allowGUI=False, allowStencil=False,
    monitor=u'testMonitor', color=[-0.5,-0.5,-0.5], colorSpace='rgb',
    blendMode='add', useFBO=True)

polygon1 = visual.Rect(
    win=win, name='polygon',units='height', 
    width=(0.2,0.2)[0], height=(0.2,0.2)[1],
    ori=0, pos=[0,0.2],
    lineWidth=0,
    fillColorSpace='rgb',
    fillColor=(1,-1,-1), # expected as red
    opacity=1.0)
polygon2 = visual.Rect(
    win=win, name='polygon',units='height', 
    width=(0.2,0.2)[0], height=(0.2,0.2)[1],
    ori=0, pos=[0,-0.2],
    lineWidth=0,
    fillColorSpace='rgb',
    fillColor=(1,0,0), # expected as pale red (pink)
    opacity=1.0)

polygon1.draw()
polygon2.draw()
win.flip()
core.wait(1.0)

win.close()
core.quit()

Maybe you haven’t fully understood the nature of the signed color space (that -1 is black and 0 is grey or maybe you haven’t understood that the addition is also signed.

To use your example of bg=(-1,-1,-1) and a stim of (1,0,0). If these are added then the expected color is (-1,-1,-1)+(1,0,0) = (0,-1,-1) but the color (0,-1,-1) is a dark red (127,0,0 in traditional rgb255 color space)

With useFBO=False you aren’t getting proper signed adding (the FBO is required to add negative numbers). You should also be getting a warning that you need to turn useFBO on

Many thanks again. I think I understood adding signed colours, but probably misunderstood opacity. I tought addition means some like o*FG+(1-o)*BG, but this seems to be wrong.
I didn’t understand FBO well, either.

I thought it could be a new bug because the same code run all fine upto 1.85.x, but please forget it if the new operation is correct.

H.