Can't get ShaderToy shaders to work with Magic Performer
Posted: Sun Aug 22, 2021 12:52 am
Hi,
I have recently installed Magic Performer v2.31 64bit.
I am trying to get this 2D EQ ShaderToy working..
https://www.shadertoy.com/view/Mlj3WV
ShaderToy shaders implement the mainImage function.
void mainImage( out vec4 fragColor, in vec2 fragCoord )
From reading the forums I know to add the following to the end of cut-paste from ShaderToy.
void main(void) {
mainImage(gl_FragColor, gl_FragCoord.xy);
}
But I still just get black screen. I have tried other shaders from ShaderToy with same result. The Shaders that come with Magic work ok. (have main())
I'm not sure what I might be missing. If someone can get a ShaderToy working with Magic Performer., and input is welcomed. Thank you. Kevin
2D_EQ.txt
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iTime; // shader playback time (in seconds)
uniform float iTimeDelta; // render time (in seconds)
uniform int iFrame; // shader playback frame
uniform float iChannelTime[4]; // channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; // (year, month, day, time in seconds)
uniform float iSampleRate; // sound sample rate (i.e., 44100)
// ...paste the shadertoy code here...
/*
2D LED Spectrum - Visualiser
Based on Led Spectrum Analyser by: simesgreen - 27th February, 2013 https://www.shadertoy.com/view/Msl3zr
2D LED Spectrum by: uNiversal - 27th May, 2015
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
*/
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// create pixel coordinates
vec2 uv = fragCoord.xy / iResolution.xy;
// quantize coordinates
const float bands = 30.0;
const float segs = 40.0;
vec2 p;
p.x = floor(uv.x*bands)/bands;
p.y = floor(uv.y*segs)/segs;
// read frequency data from first row of texture
float fft = texture( iChannel0, vec2(p.x,0.0) ).x;
// led color
vec3 color = mix(vec3(0.0, 2.0, 0.0), vec3(2.0, 0.0, 0.0), sqrt(uv.y));
// mask for bar graph
float mask = (p.y < fft) ? 1.0 : 0.1;
// led shape
vec2 d = fract((uv - p) *vec2(bands, segs)) - 0.5;
float led = smoothstep(0.5, 0.35, abs(d.x)) *
smoothstep(0.5, 0.35, abs(d.y));
vec3 ledColor = led*color*mask;
// output final color
fragColor = vec4(ledColor, 1.0);
}
// ...end paste the shadertoy code
// Add main to work with Magic, but still get black screen.
void main(void) {
mainImage(gl_FragColor, gl_FragCoord.xy);
}
I have recently installed Magic Performer v2.31 64bit.
I am trying to get this 2D EQ ShaderToy working..
https://www.shadertoy.com/view/Mlj3WV
ShaderToy shaders implement the mainImage function.
void mainImage( out vec4 fragColor, in vec2 fragCoord )
From reading the forums I know to add the following to the end of cut-paste from ShaderToy.
void main(void) {
mainImage(gl_FragColor, gl_FragCoord.xy);
}
But I still just get black screen. I have tried other shaders from ShaderToy with same result. The Shaders that come with Magic work ok. (have main())
I'm not sure what I might be missing. If someone can get a ShaderToy working with Magic Performer., and input is welcomed. Thank you. Kevin
2D_EQ.txt
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iTime; // shader playback time (in seconds)
uniform float iTimeDelta; // render time (in seconds)
uniform int iFrame; // shader playback frame
uniform float iChannelTime[4]; // channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; // (year, month, day, time in seconds)
uniform float iSampleRate; // sound sample rate (i.e., 44100)
// ...paste the shadertoy code here...
/*
2D LED Spectrum - Visualiser
Based on Led Spectrum Analyser by: simesgreen - 27th February, 2013 https://www.shadertoy.com/view/Msl3zr
2D LED Spectrum by: uNiversal - 27th May, 2015
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
*/
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// create pixel coordinates
vec2 uv = fragCoord.xy / iResolution.xy;
// quantize coordinates
const float bands = 30.0;
const float segs = 40.0;
vec2 p;
p.x = floor(uv.x*bands)/bands;
p.y = floor(uv.y*segs)/segs;
// read frequency data from first row of texture
float fft = texture( iChannel0, vec2(p.x,0.0) ).x;
// led color
vec3 color = mix(vec3(0.0, 2.0, 0.0), vec3(2.0, 0.0, 0.0), sqrt(uv.y));
// mask for bar graph
float mask = (p.y < fft) ? 1.0 : 0.1;
// led shape
vec2 d = fract((uv - p) *vec2(bands, segs)) - 0.5;
float led = smoothstep(0.5, 0.35, abs(d.x)) *
smoothstep(0.5, 0.35, abs(d.y));
vec3 ledColor = led*color*mask;
// output final color
fragColor = vec4(ledColor, 1.0);
}
// ...end paste the shadertoy code
// Add main to work with Magic, but still get black screen.
void main(void) {
mainImage(gl_FragColor, gl_FragCoord.xy);
}