/usr/share/psychtoolbox-3/PsychDemos/ExpandingSinesShader.frag.txt is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | /* ExpandingSines shader
* Draws a sequence of rings of slowly alternating color. The center
* of all rings is assigned in 'RingCenter' by the Matlab script,
* width of a ring is assigned in 'RingWidth', the radius of the
* outermost ring is assigned in 'Radius', a shift (scrolling offset)
* is assigned in 'Shift'. See ExpandingRingsDemo.m for explanation.
*
*
* Written 2011 by Mario Kleiner, licensed to you under MIT license.
*/
#version 110
const float twopi = 2.0 * 3.141592654;
uniform vec2 RingCenter;
/* Values passed from vertex shader: */
varying float RingWidth;
varying float Radius;
varying float Shift;
varying vec4 firstColor;
varying vec4 secondColor;
void main()
{
/* Query current output texel position: */
vec2 pos = gl_TexCoord[0].xy;
/* Compute euclidean distance to center of our ring stim: */
float d = distance(pos, RingCenter);
/* If distance greater than maximum radius, discard this pixel: */
if (d > Radius) discard;
/* Convert distance from units of pixels into units of ringwidths, apply shift offset: */
d = 0.5 * (1.0 + sin((d - Shift) / RingWidth * twopi));
/* Mix the two colors stored in gl_Color and secondColor, using the slow
* sine-wave weight term in d as a mix weight between 0.0 and 1.0:
*/
gl_FragColor = mix(firstColor, secondColor, d);
}
|