mirror of
https://github.com/psychopy/psychojs.git
synced 2025-05-10 18:50:54 +00:00
phase parameter for grating functions is now multiples of those function's periods
This commit is contained in:
parent
b0c7493a57
commit
c6aacad99c
@ -40,7 +40,7 @@ import raisedCosShader from "./shaders/raisedCosShader.frag";
|
|||||||
* @param {String | HTMLImageElement} [options.mask] - the name of the mask resource or HTMLImageElement corresponding to the mask
|
* @param {String | HTMLImageElement} [options.mask] - the name of the mask resource or HTMLImageElement corresponding to the mask
|
||||||
* @param {String} [options.units= "norm"] - the units of the stimulus (e.g. for size, position, vertices)
|
* @param {String} [options.units= "norm"] - the units of the stimulus (e.g. for size, position, vertices)
|
||||||
* @param {number} [options.sf=1.0] - spatial frequency of the function used in grating stimulus
|
* @param {number} [options.sf=1.0] - spatial frequency of the function used in grating stimulus
|
||||||
* @param {number} [options.phase=1.0] - phase of the function used in grating stimulus
|
* @param {number} [options.phase=0.0] - phase of the function used in grating stimulus, multiples of period of that function
|
||||||
* @param {Array.<number>} [options.pos= [0, 0]] - the position of the center of the stimulus
|
* @param {Array.<number>} [options.pos= [0, 0]] - the position of the center of the stimulus
|
||||||
* @param {number} [options.ori= 0.0] - the orientation (in degrees)
|
* @param {number} [options.ori= 0.0] - the orientation (in degrees)
|
||||||
* @param {number} [options.size] - the size of the rendered image (DEFAULT_STIM_SIZE_PX will be used if size is not specified)
|
* @param {number} [options.size] - the size of the rendered image (DEFAULT_STIM_SIZE_PX will be used if size is not specified)
|
||||||
@ -142,7 +142,8 @@ export class GratingStim extends util.mix(VisualStim).with(ColorMixin)
|
|||||||
shader: sinShader,
|
shader: sinShader,
|
||||||
uniforms: {
|
uniforms: {
|
||||||
uFreq: 1.0,
|
uFreq: 1.0,
|
||||||
uPhase: 0.0
|
uPhase: 0.0,
|
||||||
|
uColor: [.5, 0, .5]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sqr: {
|
sqr: {
|
||||||
|
@ -18,9 +18,10 @@ out vec4 shaderOut;
|
|||||||
#define M_PI 3.14159265358979
|
#define M_PI 3.14159265358979
|
||||||
uniform float uFreq;
|
uniform float uFreq;
|
||||||
uniform float uPhase;
|
uniform float uPhase;
|
||||||
|
uniform vec3 uColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 uv = vUvs;
|
vec2 uv = vUvs;
|
||||||
float s = sin(uFreq * uv.x * 2. * M_PI + uPhase);
|
float s = sin((uFreq * uv.x + uPhase) * 2. * M_PI);
|
||||||
shaderOut = vec4(.5 + .5 * vec3(s), 1.0);
|
shaderOut = vec4((.5 + .5 * vec3(s)) * uColor, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,14 @@ in vec2 vUvs;
|
|||||||
out vec4 shaderOut;
|
out vec4 shaderOut;
|
||||||
|
|
||||||
#define M_PI 3.14159265358979
|
#define M_PI 3.14159265358979
|
||||||
|
#define PI2 2.* M_PI
|
||||||
uniform float uFreq;
|
uniform float uFreq;
|
||||||
uniform float uPhase;
|
uniform float uPhase;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 uv = vUvs;
|
vec2 uv = vUvs;
|
||||||
float sx = sin(uFreq * uv.x * 2. * M_PI + uPhase);
|
float sx = sin((uFreq * uv.x + uPhase) * PI2);
|
||||||
float sy = sin(uFreq * uv.y * 2. * M_PI + uPhase);
|
float sy = sin((uFreq * uv.y + uPhase) * PI2);
|
||||||
float s = sx * sy * .5 + .5;
|
float s = sx * sy * .5 + .5;
|
||||||
shaderOut = vec4(vec3(s), 1.0);
|
shaderOut = vec4(vec3(s), 1.0);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,6 @@ uniform float uPhase;
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 uv = vUvs;
|
vec2 uv = vUvs;
|
||||||
float s = sign(sin(uFreq * uv.x * 2. * M_PI + uPhase));
|
float s = sign(sin((uFreq * uv.x + uPhase) * 2. * M_PI));
|
||||||
shaderOut = vec4(.5 + .5 * vec3(s), 1.0);
|
shaderOut = vec4(.5 + .5 * vec3(s), 1.0);
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,14 @@ in vec2 vUvs;
|
|||||||
out vec4 shaderOut;
|
out vec4 shaderOut;
|
||||||
|
|
||||||
#define M_PI 3.14159265358979
|
#define M_PI 3.14159265358979
|
||||||
|
#define PI2 2.* M_PI
|
||||||
uniform float uFreq;
|
uniform float uFreq;
|
||||||
uniform float uPhase;
|
uniform float uPhase;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 uv = vUvs;
|
vec2 uv = vUvs;
|
||||||
float sx = sign(sin(uFreq * uv.x * 2. * M_PI + uPhase));
|
float sx = sign(sin((uFreq * uv.x + uPhase) * PI2));
|
||||||
float sy = sign(sin(uFreq * uv.y * 2. * M_PI + uPhase));
|
float sy = sign(sin((uFreq * uv.y + uPhase) * PI2));
|
||||||
float s = sx * sy * .5 + .5;
|
float s = sx * sy * .5 + .5;
|
||||||
shaderOut = vec4(vec3(s), 1.0);
|
shaderOut = vec4(vec3(s), 1.0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user