LibCarna Version 3.4.0
Loading...
Searching...
No Matches
mr-edgedetect.frag
1#version 330
2
3/*
4 * Copyright (C) 2010 - 2016 Leonid Kostrykin
5 *
6 * Chair of Medical Engineering (mediTEC)
7 * RWTH Aachen University
8 * Pauwelsstr. 20
9 * 52074 Aachen
10 * Germany
11 *
12 *
13 * Copyright (C) 2021 - 2025 Leonid Kostrykin
14 *
15 */
16
17uniform sampler2D labelMap;
18uniform vec4 color;
19uniform vec2 steps;
20
21in vec2 textureCoordinates;
22
23layout( location = 0 ) out vec4 _gl_FragColor;
24
25
26// ----------------------------------------------------------------------------------
27// Fragment Procedure
28// ----------------------------------------------------------------------------------
29
30void main()
31{
32 vec2 tc = textureCoordinates;
33
34 float edgeScore
35 = abs( texture( labelMap, vec2( tc.x - steps.x, tc.y ) ).r - texture( labelMap, vec2( tc.x + steps.x, tc.y ) ).r )
36 + abs( texture( labelMap, vec2( tc.x, tc.y - steps.y ) ).r - texture( labelMap, vec2( tc.x, tc.y + steps.y ) ).r );
37
38 if( edgeScore > 0 )
39 {
40 _gl_FragColor = color;
41 }
42 else
43 {
44 discard;
45 }
46}