#version 450 layout(location = 0) in vec3 fragColor; layout(location = 1) in vec3 fragLineStart; layout(location = 2) in vec3 fragLineEnd; layout(location = 0) out vec4 outColor; void main() { vec2 fragPos = gl_FragCoord.xy; vec2 start = (fragLineStart.xy * 0.5 + 0.5) * 480.0; vec2 end = (fragLineEnd.xy * 0.5 + 0.5) * 480.0; vec2 lineDir = end - start; float lineLength = length(lineDir); if (lineLength < 1.0) { outColor = vec4(fragColor, 1.0); return; } lineDir = normalize(lineDir); vec2 toFrag = fragPos - start; float projection = dot(toFrag, lineDir); projection = clamp(projection, 0.0, lineLength); vec2 closestPoint = start + lineDir * projection; float distanceToLine = length(fragPos - closestPoint); float lineWidth = 6.0; if (distanceToLine > lineWidth) { discard; } float dashLength = 50.0; float gapLength = 20.0; float patternLength = dashLength + gapLength; float patternPos = mod(projection, patternLength); if (patternPos > dashLength) { discard; } outColor = vec4(fragColor, 1.0); }