wizgrav / clubber

Application of music theory in audio reactive visualizations
http://wizgrav.github.io/clubber
MIT License
362 stars 23 forks source link

cannot load shadertoys with multiple inputs #13

Closed alvarobyrne closed 5 years ago

alvarobyrne commented 6 years ago

Hello Can't load shadertoys with multiple inputs. This is more a question than an issue. First created this : https://codepen.io/alvarobyrne/pen/rQzoOz (stressing detailed view here: https://codepen.io/alvarobyrne/details/rQzoOz /) And could load a shader with no inputs. fine? isn't it?

Then I forked that one into this second one, which is the main concern to this issue: https://codepen.io/alvarobyrne/pen/JeyVNB but couldn't load shadertoys with multiple inputs (by clicking on top left menu items, conveniently labeled) even though I found out that texture creation in the 'getChannels' function in tool/main.js is wrong. Line 122, https://github.com/wizgrav/clubber/blob/master/tool/main.js#L122 should be something like

ret["iChannel"+i] = twgl.createTexture(gl,{ src: pf+ch.src });

more or less like in line 171 of the second codepen linked above. Line 120 https://github.com/wizgrav/clubber/blob/master/tool/main.js#L120 should also be fixed along same line.

But even though finding that error, the shadertoy doesn't load and CORS has definitely have to do with it not loading, but why are assets(only images/textures tested) loaded as images with no problem, but twgl can't load them?. Assets are loaded as images like in line 120 of the second codepen linked above, namely, images loaded top right on div with red background when clicking items on top left, dat-gui, menu.

dev tools console spits very different error messaging (after clicking on dat-gui top left menu items) when 'is_cross_origin' checkbox is toggled.

What else should be considered? I don't fully understand texture creation by twgl library nor in general.

for reference here is twgl doc for twgl's 'createTexture' function: http://twgljs.org/docs/module-twgl.html#.createTexture: haven't looked into the options object enough.

hoping the point to be clear I once again thank you for clubber, and thank you in advance for any time you spend looking at this.

alvarobyrne commented 6 years ago

None of defaultShaders in line 9 of the second codepen are multipass. They do have multiple inputs but none of them is multipass, or so I think. Here are them for reference https://www.shadertoy.com/view/4dKcWK https://www.shadertoy.com/view/MtVGRm https://www.shadertoy.com/view/MssyD8 https://www.shadertoy.com/view/Ms3SR2 https://www.shadertoy.com/view/ltyGRV https://www.shadertoy.com/view/ldXGW4 https://www.shadertoy.com/view/4t3fWs

wizgrav commented 5 years ago

I know it's been a long time since this issue is opened but my current plan is to take out all shader stuff from the main clubber project and leave the bare bones rhythm detection with some simple examples. For easy integration of glsl with clubber one could use rayglider or cook up a shadertoy like setup himself. Reinventing the wheel seems futile at least as part of this lib