- }
- }
-
-// in/out textures
- fb_texture *in = new fb_texture(w, h, color_model);
- in->bind(0);
- in->read_screen(0,0, w,h);
- fb_texture *out = new fb_texture(w, h, color_model);
-
- unsigned int frag_shader =
- VFrame::make_shader(0, in_vertex_frag, feather_frag, 0);
- if( frag_shader > 0 ) {
- GLuint points[1];
- glGenBuffers(1, points);
- for(int k = 0; k < total_submasks; k++) {
- MaskEdge &edge = *edges[k];
- if( !edge.size() ) continue;
- if( !faders[k] ) continue;
- if( !feathers[k] ) continue;
- MaskSpots spots;
- for( int i=0; i<edge.size(); ++i ) {
- MaskCoord &a = edge[i];
- MaskCoord &b = i<edge.size()-1 ? edge[i+1] : edge[0];
- draw_spots(spots, a.x,a.y+h, b.x,b.y+h);
+ in->read_screen(0,0, w,h);
+//in->write_tex("/tmp/in0.ppm");
+ if( r ) {
+ double sig2 = -log(255.0)/(r*r);
+ int n = abs((int)r) + 1;
+ if( n > MAX_FEATHER+1 ) n = MAX_FEATHER+1;
+ float psf[n]; // point spot fn
+ for( int i=0; i<n; ++i )
+ psf[i] = exp(i*i * sig2);
+ glUseProgram(feather_shader);
+ glUniform1fv(glGetUniformLocation(feather_shader, "psf"), n, psf);
+ glUniform1i(glGetUniformLocation(feather_shader, "n"), n);
+ glUniform2f(glGetUniformLocation(feather_shader, "dxy"), tw, 0.);
+ glUniform2f(glGetUniformLocation(feather_shader, "twh"), tw1, th1);
+ glUniform1i(glGetUniformLocation(feather_shader, "tex"), 0);
+ in->bind(0);
+ out->set_output_texture();
+ out->draw_texture(0,0, w,h, 0,0, w,h);
+ out->unset_output_texture();
+//out->write_tex("/tmp/out1.ppm");
+ fb_texture *t = in; in = out; out = t;
+ glUniform2f(glGetUniformLocation(feather_shader, "dxy"), 0., th);
+ in->bind(0);
+ out->set_output_texture();
+ out->draw_texture(0,0, w,h, 0,0, w,h);
+ out->unset_output_texture();
+//out->write_tex("/tmp/out2.ppm");
+ glUseProgram(0);
+ t = in; in = out; out = t;