Closed dshimaoka closed 3 years ago
I know very little about shaders, unfortunately. The times I have made changes I relied on very minor changes of existing code.
I don't think I quite understand....
multiGaborsOriOffset is in degrees in Matlab but needs to be in radians in the fragment shader?
... and you want a way to compute new values in radians, from the supplied values in degrees, inside the shader?
BUT, multiGaborsOriOffset is declared 'uniform' in the shader, so you can't modify it (the uniform declaration basically tells the compiler it doesn't change and so the compiler can optimise a lot).
Is that right?
The proposed solution is to convert to radian in Matlab and then glUniform1fv() to poke the converted values into multiGaborsOriOffset in the shader.
I'm a complete hack when it comes to GLSL (I know just enough to be dangerous), but that seems ok to me. But the code is clunky on the Matlab side while everything else is much nicer... everything else is just passed to the shader and the magic happens.
What is the alternative? Maybe create a float offset
variable in the fragment shader, and convert each element of multiGaborsOriOffset to radians as you iterate over it in the fragment shader, storing the converted value in offset, and then adding offset to orientation...? I guess the cost is that you'd be doing a lot of (re-)conversions of constant values.
Hi thanks for the comments.
Indeed I was not able to change this uniform variable inside GLSL. As Shaun suggested, the only available option seems to do it glUniform1fv. A version modified in this way has been "pull request"ed above. Our opinions now converged, I suppose.
Sorry for the delay.
thanks!
Added a new property "square", which enables squared wave in visual space (not in time). Also, multiGaborsOriOffset property can be now specified explicitly (rather than randomly assigned or regularly spaced). Together, this commit enables "checkerboard" stimuli.