Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/skybox/Media/materials/programs/LaplaceFP.cg @ 9352

Last change on this file since 9352 was 390, checked in by landauf, 17 years ago

added materials

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.