1 | ///////////////////////////////////////////////////////////////////////////////
|
---|
2 | //
|
---|
3 | // ## ######
|
---|
4 | // ###### ###
|
---|
5 | // ## ############### Shark 3D Engine (www.shark3d.com)
|
---|
6 | // ########## # # #
|
---|
7 | // ######## Copyright (c) 1996-2006 Spinor GmbH.
|
---|
8 | // ######### # # # All rights reserved.
|
---|
9 | // ## ##########
|
---|
10 | // ##
|
---|
11 | //
|
---|
12 | ///////////////////////////////////////////////////////////////////////////////
|
---|
13 |
|
---|
14 | uniform sampler2D brightTex;
|
---|
15 |
|
---|
16 | uniform vec4 filterInfo;
|
---|
17 |
|
---|
18 | varying vec2 screen;
|
---|
19 | varying vec2 scale;
|
---|
20 |
|
---|
21 | ///////////////////////////////////////////////////////////////////////////////
|
---|
22 |
|
---|
23 | const vec2 offsPix0 = vec2( 1, 0);
|
---|
24 | const vec2 offsPix1 = vec2(-1, 0);
|
---|
25 | const vec2 offsPix2 = vec2( 0, 1);
|
---|
26 | const vec2 offsPix3 = vec2( 0, -1);
|
---|
27 | const vec2 offsPix4 = vec2( 1, 1);
|
---|
28 | const vec2 offsPix5 = vec2(-1, 1);
|
---|
29 | const vec2 offsPix6 = vec2( 1, -1);
|
---|
30 | const vec2 offsPix7 = vec2(-1, -1);
|
---|
31 |
|
---|
32 | ///////////////////////////////////////////////////////////////////////////////
|
---|
33 |
|
---|
34 | void main(void)
|
---|
35 | {
|
---|
36 | // Main depth and color:
|
---|
37 |
|
---|
38 | gl_FragColor = texture2D(brightTex, screen.xy);
|
---|
39 |
|
---|
40 | float full = 2.0 * abs(gl_FragColor.x - 0.5);
|
---|
41 | float treshold = 0.99;
|
---|
42 | float delta = treshold - full;
|
---|
43 |
|
---|
44 | if(delta >= 0.0)
|
---|
45 | {
|
---|
46 | // neightbor texture coordinates:
|
---|
47 | vec2 neigh0 = offsPix0 * scale.xy + screen.xy;
|
---|
48 | vec2 neigh1 = offsPix1 * scale.xy + screen.xy;
|
---|
49 | vec2 neigh2 = offsPix2 * scale.xy + screen.xy;
|
---|
50 | vec2 neigh3 = offsPix3 * scale.xy + screen.xy;
|
---|
51 | vec2 neigh4 = offsPix4 * scale.xy + screen.xy;
|
---|
52 | vec2 neigh5 = offsPix5 * scale.xy + screen.xy;
|
---|
53 | vec2 neigh6 = offsPix6 * scale.xy + screen.xy;
|
---|
54 | vec2 neigh7 = offsPix7 * scale.xy + screen.xy;
|
---|
55 |
|
---|
56 | // Lookup colors:
|
---|
57 |
|
---|
58 | vec4 colA, colB;
|
---|
59 | colA.x = texture2D(brightTex, neigh0).x;
|
---|
60 | colA.y = texture2D(brightTex, neigh1).x;
|
---|
61 | colA.z = texture2D(brightTex, neigh2).x;
|
---|
62 | colA.w = texture2D(brightTex, neigh3).x;
|
---|
63 | colB.x = texture2D(brightTex, neigh4).x;
|
---|
64 | colB.y = texture2D(brightTex, neigh5).x;
|
---|
65 | colB.z = texture2D(brightTex, neigh6).x;
|
---|
66 | colB.w = texture2D(brightTex, neigh7).x;
|
---|
67 |
|
---|
68 | float sum = gl_FragColor.x
|
---|
69 | + dot(colA + colB, vec4(1.0, 1.0, 1.0, 1.0));
|
---|
70 | gl_FragColor = vec4(sum * 0.11111111);
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 | ///////////////////////////////////////////////////////////////////////////////
|
---|