Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/LaplaceFP.glsles @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 5 years ago

Updated programs and adjusted Material to work with GLSL>150

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