Previous topicNext topic

"varying" parameter in shaders

Questions, comments, feedback, etc.
Post Reply
neoz
Posts: 28
Joined: Mon Feb 16, 2015 2:07 pm

"varying" parameter in shaders

Post by neoz »

Hi guyz!
Long time i can't understand why some shaders not working... and i found the reason at least in my case!
There's problem with "varying" parameter - MMV can't use it or i do smth wrong?
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
varying vec2 surfacePosition;
uniform vec2 mouse;
void main( void ) {
vec2 pos = vec2(0,0);
vec3 color = vec3(1,1,1);
float dist = 0.5+0.5*cos(mouse.x*-20.0+300.0*pow(max(0.01,distance(pos,surfacePosition)),0.1));
gl_FragColor = vec4(color * dist, 1.0);
}
neoz
Posts: 28
Joined: Mon Feb 16, 2015 2:07 pm

Re: "varying" parameter in shaders

Post by neoz »

But some great shaders still not working in MMV, but in glslsandbox its fine...
Is there any reason? :|
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
uniform sampler2D buf;
void main(void)
{
vec2 pos = (gl_FragCoord.xy/resolution-0.5)*vec2(resolution.x/resolution.y,1.0);
float hist =
texture2D(buf,vec2(length(pos),fract(atan(pos.y,pos.x)/6.2831853))).a;
//texture2D(buf,gl_FragCoord.xy/resolution).a;
float new = (gl_FragCoord.x < 5.0) ?
//smoothstep(0.0, 0.5, abs(abs(fract(distance(mouse.x*4.0,pos.y)))-0.5))
cos((mouse.x*4.0+pos.y)*6.2831853)*0.5+0.5
: texture2D(buf,(gl_FragCoord.xy-vec2(1.0,0.0))/resolution).a;
vec3 color1 = vec3(0.0,0.0,0.0);
vec3 color2 = vec3(0.0,1.0,0.0);
gl_FragColor = vec4(mix(color1,color2,hist), new);
}
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: "varying" parameter in shaders

Post by Magic »

Interesting! I'll have a look at this.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: "varying" parameter in shaders

Post by Magic »

Ok... you're right, there were a couple small bugs there. They should be fixed when version 1.6 is released.

Thanks!
neoz
Posts: 28
Joined: Mon Feb 16, 2015 2:07 pm

Re: "varying" parameter in shaders

Post by neoz »

Great!!
Thank you Eric!!!
:mrgreen:
Post Reply