Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/programs/glow.cg @ 12366

Last change on this file since 12366 was 11088, checked in by landauf, 9 years ago

improved glow effects

File size: 2.1 KB
Line 
1//A.
2float4 GlowX_fp
3        (
4                float2 uv: TEXCOORD0,
5
6                uniform sampler2D scene: register(s0),
7                uniform float4 invTexSize
8        ) : COLOR
9#define RENDER_SCENE 1
10#define BLUR_RADIUS 1
11{
12        float4 colour = float4(0);
13        float blurSize = BLUR_RADIUS * invTexSize.x;
14
15        //X-blur.
16        int x = uv.x/blurSize;
17        colour += tex2D(scene, float2((x - 4.0) * blurSize, uv.y)) * 1.0/25.0;
18        colour += tex2D(scene, float2((x - 3.0) * blurSize, uv.y)) * 2.0/25.0;
19        colour += tex2D(scene, float2((x - 2.0) * blurSize, uv.y)) * 3.0/25.0;
20        colour += tex2D(scene, float2((x - 1.0) * blurSize, uv.y)) * 4.0/25.0;
21        colour += tex2D(scene, float2((x + 0.0) * blurSize, uv.y)) * 5.0/25.0;
22        colour += tex2D(scene, float2((x + 1.0) * blurSize, uv.y)) * 4.0/25.0;
23        colour += tex2D(scene, float2((x + 2.0) * blurSize, uv.y)) * 3.0/25.0;
24        colour += tex2D(scene, float2((x + 3.0) * blurSize, uv.y)) * 2.0/25.0;
25        colour += tex2D(scene, float2((x + 4.0) * blurSize, uv.y)) * 1.0/25.0;
26
27        return colour;
28}
29
30//B.
31float4 GlowY_fp
32        (
33                float2 uv: TEXCOORD0,
34 
35                uniform sampler2D blurX: register(s0),
36                uniform float4 invTexSize
37        ) : COLOR
38{
39        float4 colour = float4(0);
40        float blurSize = BLUR_RADIUS * invTexSize.y;
41
42        //Y-blur.
43        int y = uv.y/blurSize;
44        colour += tex2D(blurX, float2(uv.x, (y - 4.0) * blurSize)) * 1.0/25.0;
45        colour += tex2D(blurX, float2(uv.x, (y - 3.0) * blurSize)) * 2.0/25.0;
46        colour += tex2D(blurX, float2(uv.x, (y - 2.0) * blurSize)) * 3.0/25.0;
47        colour += tex2D(blurX, float2(uv.x, (y - 1.0) * blurSize)) * 4.0/25.0;
48        colour += tex2D(blurX, float2(uv.x, (y + 0.0) * blurSize)) * 5.0/25.0;
49        colour += tex2D(blurX, float2(uv.x, (y + 1.0) * blurSize)) * 4.0/25.0;
50        colour += tex2D(blurX, float2(uv.x, (y + 2.0) * blurSize)) * 3.0/25.0;
51        colour += tex2D(blurX, float2(uv.x, (y + 3.0) * blurSize)) * 2.0/25.0;
52        colour += tex2D(blurX, float2(uv.x, (y + 4.0) * blurSize)) * 1.0/25.0;
53
54        return colour;
55}
56
57//C.
58float4 GlowBlend_fp
59        (
60                float2 uv: TEXCOORD0,
61
62                uniform sampler2D scene: register(s0),
63                uniform sampler2D blurXY: register(s1)
64        ) : COLOR
65{
66        //Add this to original, return.
67        return
68#if RENDER_SCENE
69                tex2D(scene, uv) +
70#endif
71                tex2D(blurXY, uv) * 1;
72}
Note: See TracBrowser for help on using the repository browser.