source: GTP/trunk/App/Demos/Illum/Shark3D/version164x12u/IllumDemo/src/res/levelutil/shader/prog/ogl_glsl/lightfilter_ogl_glsl_fs1x0.s3d_shadercode @ 2196

Revision 2196, 2.4 KB checked in by szirmay, 17 years ago (diff)
Line 
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
14uniform sampler2D brightTex;
15
16uniform vec4 filterInfo;
17
18varying vec2 screen;
19varying vec2 scale;
20
21///////////////////////////////////////////////////////////////////////////////
22
23const vec2 offsPix0 = vec2( 1,  0);
24const vec2 offsPix1 = vec2(-1,  0);
25const vec2 offsPix2 = vec2( 0,  1);
26const vec2 offsPix3 = vec2( 0, -1);
27const vec2 offsPix4 = vec2( 1,  1);
28const vec2 offsPix5 = vec2(-1,  1);
29const vec2 offsPix6 = vec2( 1, -1);
30const vec2 offsPix7 = vec2(-1, -1);
31
32///////////////////////////////////////////////////////////////////////////////
33
34void 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///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.