Page 1 of 1

Glsl inputs

Posted: Mon Aug 05, 2019 10:04 pm
by D.pro
Hi 8-)
Please somebody help me!
I want to know the input points of glsl’s node in MMV what are they for?
Is this somthing like ichannels inputs of shadertoy’s glsl models? Or what?
Thanks for supports :arrow:

Re: Glsl inputs

Posted: Tue Aug 06, 2019 12:06 am
by Terry Payman
Yes, like Shadertoy's ichannels inputs.

Note that you'll see an input pin whether or not it is used in a particular shader, so the input will be non-functional for many GLSL modules.
Note also, even if a GLSL module does have multiple inputs used, when first added to a Magic scene it will only show one input pin.

Here's one I wrote a couple of years ago to add four inputs together. It may well be poorly coded, but it works.
If you copy the green code below into a file called Add4.txt and load that into the GLSLShader module you can try it in Magic.

You'll see only one input when added to your project but as you add more connections the number of input pins will increase. Any connection beyond the first four will be ignored by the module.

void main()
{
vec4 col0 = texture2D(iChannel0, gl_FragCoord.xy / iResolution.xy);
vec4 col1 = texture2D(iChannel1, gl_FragCoord.xy / iResolution.xy);
vec4 col2 = texture2D(iChannel2, gl_FragCoord.xy / iResolution.xy);
vec4 col3 = texture2D(iChannel3, gl_FragCoord.xy / iResolution.xy);

gl_FragColor = col0+col1+col2+col3;
}


Nowadays you're much better off using ISF modules if you want to create your own functionality - you can give meaningful names to the inputs (amongst many other benefits such being able to name/search for a module, and Vidvox's ISF editor which will show the location of any errors in the code).

ISF use in Magic: https://magicmusicvisuals.com/downloads ... e.html#ISF
ISF introduction: https://vdmx.vidvox.net/blog/isf
ISF editor for Mac: https://vdmx.vidvox.net/tutorials/using-the-isf-editor
ISF editor for Windows (beta): https://discourse.vidvox.net/t/isf-edit ... s-beta/647

Re: Glsl inputs

Posted: Tue Aug 06, 2019 11:12 am
by D.pro
thank you!
awesome! ;)
there is another issue too!
can i input some vector parameters from this trick? or fft as input?

Re: Glsl inputs

Posted: Tue Aug 06, 2019 1:01 pm
by artnik
There is an AudioToImage module included with the base install. It takes an audio input and spits out an image which can be either the frequency spectrum or the waveform, or both. It's what you need for some inputs, thinking of FFT.

Re: Glsl inputs

Posted: Tue Aug 06, 2019 5:21 pm
by Terry Payman
I don't know what you want to do with vector parameters, but each input will give you an independent scalar value so you could combine two of these to give you a vector.

Re: Glsl inputs

Posted: Tue Aug 06, 2019 9:22 pm
by D.pro
Very helpful ;)
thank you!