1// Copyright (c) 2015 Sergio Gonzalez. All rights reserved. 2// License: https://github.com/serge-rgb/milton#license 3 4in vec3 v_pointa; 5in vec3 v_pointb; 6 7uniform sampler2D u_canvas; 8 9in vec3 v_debug_color; 10 11// TODO: This whole shader should be a variation in stroke_raster.f.glsl 12 13void 14main() 15{ 16 vec2 screen_point = vec2(gl_FragCoord.x, u_screen_size.y - gl_FragCoord.y); 17 18 vec2 canvas_point = raster_to_canvas_gl(screen_point); 19 20 vec2 a = v_pointa.xy; 21 vec2 b = v_pointb.xy; 22 vec2 ab = b - a; 23 float len_ab = length(ab); 24 25 float t = clamp(dot(canvas_point - a, ab)/len_ab, 0.0, len_ab) / len_ab; 26 vec2 stroke_point = mix(a, b, t); 27 float pressure = mix(v_pointa.z, v_pointb.z, t); 28 29 if ( distance(canvas_point, a) < u_radius*0.1 ) { 30 out_color = vec4(v_debug_color, 1.0); 31 } else { 32 discard; 33 } 34}//END 35