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

Revision 2196, 2.3 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
14struct PS_INPUT
15{
16    float2 screen: TEXCOORD0;
17    float2 scale: TEXCOORD1;
18};
19
20///////////////////////////////////////////////////////////////////////////////
21
22sampler brightTex: register(s0);
23
24///////////////////////////////////////////////////////////////////////////////
25
26const float2 offsPix0 = float2( 1,  0);
27const float2 offsPix1 = float2( 0,  1);
28const float2 offsPix2 = float2( 1,  1);
29const float2 offsPix3 = float2(-1,  1);
30
31///////////////////////////////////////////////////////////////////////////////
32// Pixelshader
33// Profile: 2x0
34
35float4 main(PS_INPUT input): COLOR0
36{
37    // Main color:
38   
39    float4 result = tex2D(brightTex, input.screen.xy);
40   
41    float full = abs(2 * result.x - 1);
42    float treshold = 0.99;
43    float delta = treshold - full;
44
45    if(delta >= 0)
46    {
47        // Lookup colors:
48       
49        float4 colA, colB;
50        float2 offs0 = offsPix0 * input.scale.xy;
51        colA.x = tex2D(brightTex, input.screen.xy + offs0).x;
52        colB.x = tex2D(brightTex, input.screen.xy - offs0).x;
53        float2 offs1 = offsPix1 * input.scale.xy;
54        colA.y = tex2D(brightTex, input.screen.xy + offs1).x;
55        colB.y = tex2D(brightTex, input.screen.xy - offs1).x;
56        float2 offs2 = offsPix2 * input.scale.xy;
57        colA.z = tex2D(brightTex, input.screen.xy + offs2).x;
58        colB.z = tex2D(brightTex, input.screen.xy - offs2).x;
59        float2 offs3 = offsPix3 * input.scale.xy;
60        colA.w = tex2D(brightTex, input.screen.xy + offs3).x;
61        colB.w = tex2D(brightTex, input.screen.xy - offs3).x;
62           
63        // Calculate average:
64       
65        float sum = result.x + dot(colA + colB, float4(1, 1, 1, 1));
66        result.xyz = sum * 0.11111111;
67    }
68       
69    return result;
70}
71
72///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.