Trouble with shader
in
Programming Questions
•
9 months ago
Hello I found my desired shader shader
http://glsl.heroku.com/e # 5604,6 and tried to use it in my sketch, but it does not work. I can not understand what I'm doing wrong, please tell me what I'm doing wrong: ((
- #ifdef GL_ES
- precision mediump float;
- precision mediump int;
- #endif
- uniform float time;
- uniform vec2 mouse;
- uniform vec2 resolution;
- void main( void ) {
- vec2 position = gl_FragCoord.xy;
- float color;
- vec2 lightpos = mouse*resolution;
- vec2 norm = lightpos - position;
- float sdist = pow((norm.x * norm.x),1.0/3.0) + pow((norm.y * norm.y),1.0/3.0);
- vec3 light_color = vec3(1.2,0.8,0.6);
- color = (1.0 / (sdist * (mouse.x)))*cos(0.7*(sin(time*1.0)));
- gl_FragColor = vec4(color,color,color,1.0)*vec4(light_color,1.0);
- }
- PShader shine;
- void setup()
- {
- size(1024,768,P2D);
- shine = loadShader("shine.glsl");
- shine.set("resolution",float(width),float(height));
- }
- void draw(){
- shine.set("mouse",float(mouseX),float(mouseY));
- shine.set("time",millis()/1000.0);
- shader(shine);
- }
1