Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/skybox/Media/materials/programs/DOF_ps.cg @ 10880

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

added materials

File size: 902 bytes
Line 
1// Simple blur filter
2
3const float2 samples[8] = {
4    {-1, 1},
5    {-1, 0},
6    {-1, -1},
7    {0, -1},
8    {1, -1},
9    {1, 0},
10    {1, 1},
11    {0, 1}
12};
13
14float4 blur(
15
16    in float2 texCoord: TEXCOORD0,
17    uniform float sampleDistance: register(c0),
18    uniform sampler Blur0: register(s0)
19
20) : COLOR
21{
22   float4 sum = tex2D(Blur0, texCoord);
23   for (int i = 0; i < 8; ++i){
24      sum += tex2D(Blur0, texCoord + sampleDistance * samples[i]);
25   }
26   return sum / 9;
27}
28
29
30
31float4 blend
32(
33    in float2 texCoord: TEXCOORD0,
34
35    uniform sampler Blur0 : register(s0),
36    uniform sampler Blur1 : register(s1),
37
38    uniform float focus: register(c0),
39    uniform float range: register(c1)
40) : COLOR
41{
42   float4 sharp = tex2D(Blur0, texCoord);
43   float4 blur  = tex2D(Blur1, texCoord);
44
45   // alpha channel of sharp RT has depth info
46   return lerp(sharp, blur, saturate(range * abs(focus - sharp.a)));
47}
Note: See TracBrowser for help on using the repository browser.