Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/lod/materials/programs/LaplaceFP.cg @ 11183

Last change on this file since 11183 was 5312, checked in by landauf, 16 years ago

added shaders (compositors, materials, cg programs and textures)

  • Property svn:eol-style set to native
File size: 800 bytes
Line 
1sampler Image : register(s0);
2
3// The Laplace filter approximates the second order derivate,
4// that is, the rate of change of slope in the image. It can be
5// used for edge detection. The Laplace filter gives negative
6// response on the higher side of the edge and positive response
7// on the lower side.
8
9// This is the filter kernel:
10// 0  1  0
11// 1 -4  1
12// 0  1  0
13
14
15
16float4 Laplace_ps (float2 texCoord: TEXCOORD0,
17                        uniform float scale,
18                        uniform float pixelSize) : COLOR
19{
20
21    float2 samples[4] = {
22        0, -1,
23       -1,  0,
24        1,  0,
25        0,  1
26    };
27   float4 laplace = -4 * tex2D(Image, texCoord);
28
29   // Sample the neighbor pixels
30   for (int i = 0; i < 4; i++){
31      laplace += tex2D(Image, texCoord + pixelSize * samples[i]);
32   }
33
34   return (0.5 + scale * laplace);
35}
36
Note: See TracBrowser for help on using the repository browser.