Changeset 2190 for trunk/tutorial/04_texture.lolfx
 Timestamp:
 Jan 1, 2013, 6:43:30 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/tutorial/04_texture.lolfx
r2136 r2190 33 33 float height = 600.0; 34 34 float line_width = 1.8; 35 float dot_size = 2.0; 35 36 vec4 delta = vec4(1.0 / 128, 0.0, 36 37 2.0 / 128, 0.0); … … 45 46 c[3] = texture2D(u_Texture, tc + delta.zw).x; 46 47 47 /* Quick hack: artificially compress display in Y */48 c *= 0.3;49 50 48 vec2 p0 = vec2((tc.x  delta.x) * width, c[0] * height); 51 vec2 p1 = vec2((tc.x ) * width,c[1] * height);49 vec2 p1 = vec2((tc.x ) * width, c[1] * height); 52 50 vec2 p2 = vec2((tc.x + delta.x) * width, c[2] * height); 53 51 vec2 p3 = vec2((tc.x + delta.z) * width, c[3] * height); 54 52 vec2 a = vec2(p.x * width, p.y * height); 55 53 56 float d0 = segdist(p0, p1, a); 57 float d1 = segdist(p1, p2, a); 58 float d2 = segdist(p2, p3, a); 54 /* Compute distance to segments */ 55 float d = segdist(p0, p1, a); 56 d = min(d, segdist(p1, p2, a)); 57 d = min(d, segdist(p2, p3, a)); 59 58 60 float d = clamp(line_width  min(min(d0, d1), d2), 0.0, 1.0); 59 /* Compute distance to dots */ 60 d = min(d, length(a  p0)  dot_size); 61 d = min(d, length(a  p1)  dot_size); 62 d = min(d, length(a  p2)  dot_size); 63 d = min(d, length(a  p3)  dot_size); 64 65 /* Add line width */ 66 float lum = clamp(line_width  d, 0.0, 1.0); 67 68 /* Compensate for sRGB */ 69 lum = pow(1.0  lum, 1.0 / 2.4); 61 70 62 71 /* Choose some funny colours */ 63 gl_FragColor = vec4( p.y, d, mix(p.x, 0.3, d), 1.0);72 gl_FragColor = vec4(mix(p.x, 1.0, lum), lum, lum, 1.0); 64 73 } 65 74
Note: See TracChangeset
for help on using the changeset viewer.