Previous topicNext topic

Shaders

Questions, comments, feedback, etc.
Post Reply
flip
Posts: 2
Joined: Mon Oct 27, 2014 7:36 pm

Shaders

Post by flip »

Hello all

I have recently got Magic and have been having great fun producing synchronised visuals to my music
I am brand new to this area of video art and have absolutely no idea how to use program languages.(at the moment)
What kind of Shaders can I use in Magic and where can I download them from and what sort of price can I expect to pay?
Better still is there a program I can learn and use to produce my own Shaders that are compatible with Magic?

Cheers

Flip
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Hi Flip, Magic's shader functionality is designed primarily to work with shaders from these two sites: http://glslsandbox.com and http://shadertoy.com

The shaders on these sites are free, but not all of them are licensed for commercial use. You'll have to read each one to see how it can be used.

This section of our User's Guide might be helpful: http://magicmusicvisuals.com/downloads/ ... GLSLShader

You can't really use a program to design shaders from scratch (as far as I know); you have to write them using the GLSL language. So for now, I'd recommend you just try copying and pasting existing shaders from the sites above.

Does that help?

Eric
flip
Posts: 2
Joined: Mon Oct 27, 2014 7:36 pm

Re: Shaders

Post by flip »

Hello Eric

Thank you very much for your quick reply
I'll go and have a rout around in the sites you mentioned.

I forgot to say in my first post what an amazing and inspiring program you have made.
It's brilliant to be able craft beautiful visuals in such an easy and transparent way.

Cheers

Flip
Ranya
Posts: 18
Joined: Fri Nov 07, 2014 7:57 pm

Re: Shaders

Post by Ranya »

what is the syntax for copying and pasting the code from shaders on this site? when i copy the code i just get a blank screen

thanks
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Hmm, you shouldn't have to worry about syntax. It's just a matter of copying and pasting the code into a text file on your system. Is there a particular shader that's not working for you? Can you post the link?

Eric
Ranya
Posts: 18
Joined: Fri Nov 07, 2014 7:57 pm

Re: Shaders

Post by Ranya »

Hi Eric

none of the shaders are working for me. I am basically copying the code from shader toy pasting it on note pad and saving as textfile. Is this the right way?
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Yup, that's the right way.

How about the shaders that come with Magic? Are those working for you? You might want to look at one of them in a text editor to make sure you're copying and pasting the right things.
Ranya
Posts: 18
Joined: Fri Nov 07, 2014 7:57 pm

Re: Shaders

Post by Ranya »

yes all the stock shaders work well. only the downloaded ones dont. Basically what i am doing is:

1. Copying the code
2. Pasting onto note pad
3. saving the file with any name into the GLS folder in C: Magic
4. Launching the .txt file

The screen just appears blank white
Syd
Posts: 60
Joined: Thu Oct 16, 2014 10:32 am

Re: Shaders

Post by Syd »

they're probably using textures that you don't have.
Terry Payman
Posts: 711
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: Shaders

Post by Terry Payman »

Ranya wrote:yes all the stock shaders work well. only the downloaded ones dont. Basically what i am doing is:

1. Copying the code
2. Pasting onto note pad
3. saving the file with any name into the GLS folder in C: Magic
4. Launching the .txt file

The screen just appears blank white
Here's one that doesn't need a texture, and so works with just the above copy & paste:
https://www.shadertoy.com/view/MsSSRV#
If I get an all-white screen it's usually because I've missed copying the closing "}" at the very end of the ShaderToy code, or made a syntax error in a modification.
Syd wrote:they're probably using textures that you don't have.
Eric gives details in his numbered notes at the end of the GLSLShader section:
Eric wrote:...This section of our User's Guide might be helpful: http://magicmusicvisuals.com/downloads/ ... GLSLShader...
Ranya
Posts: 18
Joined: Fri Nov 07, 2014 7:57 pm

Re: Shaders

Post by Ranya »

Can i download textures or is this graphic card dependent?
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Ranya, can you post a link to a shader you're trying to use, or post the code that's not working for you? That way I can tell you exactly why it doesn't work, and hopefully fix it if possible.
Ranya
Posts: 18
Joined: Fri Nov 07, 2014 7:57 pm

Re: Shaders

Post by Ranya »

Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Ok, that one works fine for me. Try this:
MatrixRain.txt
(2.59 KiB) Downloaded 474 times
If my version works for you, you should compare it to your version and see what the difference is.
Terry Payman wrote:If I get an all-white screen it's usually because I've missed copying the closing "}" at the very end of the ShaderToy code.
As Terry said, the most common problem is that you didn't copy the last "}".
Terry Payman
Posts: 711
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: Shaders

Post by Terry Payman »

Eric wrote:As Terry said, the most common problem is that you didn't copy the last "}".
... and if I get an all-black screen (as for the "problem" Matrix Rain shader), the first thing I try is providing an input.
qobupd.jpg
qobupd.jpg (10.71 KiB) Viewed 13084 times
Likewise, if you see an all-black screen for a shader on the Shadertoy site you probably need to click on the "iChannel0" panel and select a texture as an input. It seems only some of the shaders have a texture preselected, even if it's required.
Ranya
Posts: 18
Joined: Fri Nov 07, 2014 7:57 pm

Re: Shaders

Post by Ranya »

Thanks that now worked for me.
Ranya
Posts: 18
Joined: Fri Nov 07, 2014 7:57 pm

Re: Shaders

Post by Ranya »

I still have issues with certain shaders that are either fully black or just white. It may have to do with the way i am copying and pasting or just my graphix card. Am hoping to upgrade to the GTX 970 this Xmas! if my dad agrees.
hyp
Posts: 3
Joined: Wed Mar 04, 2015 11:01 pm

Re: Shaders

Post by hyp »

hello. for the life of me, i can't get any of the shadertoy shaders to work inside of MMV. i copy and pasted them to a .txt file, loaded them up in MMV and no go.

i noticed with some of the examples posted here that the syntax was different where there was a gl_ added to some of the code. however this is weird because if you are copying/pasting directly why is your code different than mine?

sorry for the newb question, since this is all new to me. any help would be greatly appreciated. thanks!

here's one that i would really like to try:
https://www.shadertoy.com/view/ldl3W8#
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Yeah, unfortunately Shadertoy just changed their specification. No idea why they did it but it broke things for a lot of apps.

There's an easy fix though. Just copy and paste this into the bottom of your text file:

Code: Select all

void main(void) {
    mainImage(gl_FragColor, gl_FragCoord.xy);
}
The next version of Magic (1.6) will add this automatically.
hyp
Posts: 3
Joined: Wed Mar 04, 2015 11:01 pm

Re: Shaders

Post by hyp »

Eric wrote:Yeah, unfortunately Shadertoy just changed their specification. No idea why they did it but it broke things for a lot of apps.

There's an easy fix though. Just copy and paste this into the bottom of your text file:

Code: Select all

void main(void) {
    mainImage(gl_FragColor, gl_FragCoord.xy);
}
The next version of Magic (1.6) will add this automatically.
thanks so much eric! finally got it working :)
Syd
Posts: 60
Joined: Thu Oct 16, 2014 10:32 am

Re: Shaders

Post by Syd »

I've noticed since this change some shaders have a 0.0 alpha set. This doesn't effect magic, but you can trip you up if you're syphoning out etc.

example: https://www.shadertoy.com/view/MlsGRS

Code: Select all

	fragColor = vec4(final*fog,0.0);
Magic
Site Admin
Posts: 3441
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Yeah that's because of premultiplied alpha (a common theme recently it seems: http://magicmusicvisuals.com/forums/vie ... ?f=2&t=355).

Magic handles alpha the same way Shadertoy does, but other apps handle it incorrectly (er, differently). :)

For the technically-inclined, the difference in OpenGL is:

Code: Select all

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
instead of

Code: Select all

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
See http://blogs.msdn.com/b/shawnhar/archiv ... alpha.aspx for more info. The key issue is the proper handling of alpha cutouts and image composition (last sections of that article).

Also http://home.comcast.net/~tom_forsyth/bl ... lpha%5D%5D is a good one, especially the section "Compositing translucent layers".
Post Reply