Previous topicNext topic

Glsl inputs

Questions, comments, feedback, etc.
Post Reply
D.pro
Posts: 7
Joined: Wed Oct 17, 2018 6:04 am

Glsl inputs

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

Re: Glsl inputs

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

Re: Glsl inputs

Post by D.pro »

thank you!
awesome! ;)
there is another issue too!
can i input some vector parameters from this trick? or fft as input?
artnik
Posts: 268
Joined: Tue Jan 05, 2016 5:33 pm

Re: Glsl inputs

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

Re: Glsl inputs

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

Re: Glsl inputs

Post by D.pro »

Very helpful ;)
thank you!
Post Reply