Glsl inputs

Mon Aug 05, 2019 10:04 pm

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:
D.pro
 
Posts: 7
Joined: Wed Oct 17, 2018 6:04 am

Re: Glsl inputs

Tue Aug 06, 2019 12:06 am

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/Magic_UsersGuide.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-editor-for-windows-beta/647
Terry Payman
 
Posts: 542
Joined: Sun Sep 14, 2014 8:15 am
Location: UK

Re: Glsl inputs

Tue Aug 06, 2019 11:12 am

thank you!
awesome! ;)
there is another issue too!
can i input some vector parameters from this trick? or fft as input?
D.pro
 
Posts: 7
Joined: Wed Oct 17, 2018 6:04 am

Re: Glsl inputs

Tue Aug 06, 2019 1:01 pm

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.
artnik
 
Posts: 264
Joined: Tue Jan 05, 2016 5:33 pm

Re: Glsl inputs

Tue Aug 06, 2019 5:21 pm

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.
Terry Payman
 
Posts: 542
Joined: Sun Sep 14, 2014 8:15 am
Location: UK

Re: Glsl inputs

Tue Aug 06, 2019 9:22 pm

Very helpful ;)
thank you!
D.pro
 
Posts: 7
Joined: Wed Oct 17, 2018 6:04 am

Return to General Discussion

© 2019 Color & Music, LLC • This web site is mobile-friendly