Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/LaplaceFP.glsl @ 12206

Last change on this file since 12206 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 862 bytes
Line 
1#version 150
2
3uniform sampler2D Image;
4uniform float scale;
5uniform float pixelSize;
6in vec2 oUv0;
7out vec4 fragColour;
8
9// The Laplace filter approximates the second order derivate,
10// that is, the rate of change of slope in the image. It can be
11// used for edge detection. The Laplace filter gives negative
12// response on the higher side of the edge and positive response
13// on the lower side.
14
15// This is the filter kernel:
16// 0  1  0
17// 1 -4  1
18// 0  1  0
19
20void main()
21{
22    vec2 samples[4];
23        samples[0] = vec2(0, -1);
24        samples[1] = vec2(-1, 0);
25        samples[2] = vec2(1, 0);
26        samples[3] = vec2(0, 1);
27
28    mediump vec4 tc = texture(Image, oUv0);
29    vec4 laplace = -4.0 * tc;
30
31    // Sample the neighbor pixels
32    for (int i = 0; i < 4; i++){
33       laplace += texture(Image, oUv0 + pixelSize * samples[i]);
34    }
35
36    fragColour = (0.5 + scale * laplace);
37}
38
Note: See TracBrowser for help on using the repository browser.