File: buffer-wireframe.frag

package info (click to toggle)
glmark2 2023.01%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,380 kB
  • sloc: cpp: 20,680; python: 13,052; ansic: 8,595; java: 1,246; xml: 383; makefile: 42; sh: 39
file content (17 lines) | stat: -rw-r--r-- 563 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
varying vec4 dist;

const vec4 LINE_COLOR = vec4(1.0);
const vec4 TRIANGLE_COLOR = vec4(0.0, 0.5, 0.8, 0.8);

void main(void)
{
    // Get the minimum distance of this fragment from a triangle edge.
    // We need to multiply with dist.w to undo the workaround we had
    // to perform to get linear interpolation (instead of perspective correct).
    float d = min(dist.x * dist.w, min(dist.y * dist.w, dist.z * dist.w));

    // Get the intensity of the wireframe line
    float I = exp2(-2.0 * d * d);

    gl_FragColor = mix(TRIANGLE_COLOR, LINE_COLOR, I);
}