kurokida / PsychologicalOnlineShaders

GLSL shaders for online psychological experiments.
MIT License
2 stars 0 forks source link

Drawing multiple Gabor patches #1

Open least2 opened 2 years ago

least2 commented 2 years ago

Hi, I'm proposing a solution to lift the limitation you mentioned in the README that multiple Gabor patches could not be presented superimposed. First, the Gaussian envelope could be saved as the alpha channel so that the patch becomes semi-transparent. Second, compared to writing GLSL shaders that specifically draw multiple Gabor patches, it is much easier to draw only one patch at a time and save it as an image, then draw multiple semi-transparent patches on a regular 2D canvas or simply on the web page and they are superimposed.

I have created a Garborium-like demo (source). It uses gl.readPixels() to read back the pixel data of the Gabor and then draw it multiple times on a regular canvas.

kurokida commented 2 years ago

Thank you for your valuable comments and the demo program! I don't fully understand your source code yet, but at first glance it seems to work fine.

least2 commented 2 years ago

I would also recommend GPU.js for creating complex visual stimuli with WebGL in the browser.

GPU.js automatically transpiles simple JavaScript functions into shader language and compiles them so they run on your GPU.

It saves you the trouble of writing GLSL shaders by hand. Here are some examples: a drifting Gabor patch and fancy gratings

kurokida commented 2 years ago

Thanks again! This information is beneficial not only to me but to many others.