Vary drifting grating contrast

mhisted's Avatar


28 Jul, 2010 02:59 PM

The attached patch makes the alpha_multiplier parameter work to vary the contrast of the drifting_grating.
Works for me with very light testing (attached example).


  1. 1 Posted by mhisted on 28 Jul, 2010 07:23 PM

    mhisted's Avatar

    After thinking about this a bit, I should clarify: this only works when the background is at (0.5, 0.5, 0.5). However, all the gratings have a mean luminance of 0.5, as far as I can tell. So I don't think there are many reasons to use a different color background.

    One way to make it work with all backgrounds would be to get the background color and use it to set the RGB values in this patch. However it's probably cleaner to just have the grating blend correctly on the background. Because the texture uses GL_COMBINE (not GL_BLEND), I didn't spend time to figure out how to do that correctly.

  2. Support Staff 2 Posted by Christopher Sta... on 28 Jul, 2010 08:14 PM

    Christopher Stawarz's Avatar

    Thanks for the patch, Mark. I'll check it out and get back to you.


  3. 3 Posted by Mark Histed on 29 Nov, 2010 11:43 PM

    Mark Histed's Avatar

    Hi Chris,

    Any progress on this? If you have something to test I can pull the nightly and test it.


  4. Support Staff 4 Posted by Christopher Sta... on 30 Nov, 2010 04:39 PM

    Christopher Stawarz's Avatar

    Hi Mark,

    Sorry for ignoring this for so long. I wanted to think about it some more before committing it, but then it completely fell off my radar.

    Anyway, the patch seems fine, and I just committed it. It'll be in tonight's nightly build.

    For future reference: It's possible to get the same effect by drawing a semi-transparent rectangle over the grating in your experiment. I've attached an example that does this for gray, red, green, and blue backgrounds. If you ever want to adjust the contrast of a grating against a background that's not neutral gray, this is a way to do it.


  5. 5 Posted by Mark Histed on 30 Nov, 2010 08:36 PM

    Mark Histed's Avatar

    Thank you Chris. I'll look into both options next week and let you know.

  6. 6 Posted by mhisted on 08 Dec, 2010 10:30 PM

    mhisted's Avatar

    This all works. Thanks!

    One additional comment - can you add some sort of error checking on XML field names in the server? For example, if an XML property name is specified that is unsupported for that object, have the server display an error at parse time. Right now if you set the 'alpha' or 'contrast' or 'alapha_multiplier' field of a rectangle object, those fields are ignored silently.

    T hanks!

  7. 7 Posted by David Cox on 09 Dec, 2010 12:04 AM

    David Cox's Avatar

    > One additional comment - can you add some sort of error checking on XML field names in the server?

    Big changes / improvements are coming on this front. Stay tuned.

    – Dave

  8. Christopher Stawarz closed this discussion on 09 Dec, 2010 01:31 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

17 May, 2022 02:12 PM
16 May, 2022 03:12 PM
04 May, 2022 06:02 PM
03 May, 2022 01:30 PM
02 May, 2022 10:47 PM