Carna Version 3.3.3
Loading...
Searching...
No Matches
mr-edgedetect.frag
1#version 330
2
3/*
4 * Copyright (C) 2021 Leonid Kostrykin
5 *
6 */
7
8uniform sampler2D labelMap;
9uniform vec4 color;
10uniform vec2 steps;
11
12in vec2 textureCoordinates;
13
14layout( location = 0 ) out vec4 _gl_FragColor;
15
16
17// ----------------------------------------------------------------------------------
18// Fragment Procedure
19// ----------------------------------------------------------------------------------
20
21void main()
22{
23 vec2 tc = textureCoordinates;
24
25 float edgeScore
26 = abs( texture( labelMap, vec2( tc.x - steps.x, tc.y ) ).r - texture( labelMap, vec2( tc.x + steps.x, tc.y ) ).r )
27 + abs( texture( labelMap, vec2( tc.x, tc.y - steps.y ) ).r - texture( labelMap, vec2( tc.x, tc.y + steps.y ) ).r );
28
29 if( edgeScore > 0 )
30 {
31 _gl_FragColor = color;
32 }
33 else
34 {
35 discard;
36 }
37}