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 | #include \
|
---|
15 | <levelutil/shader/prog/d3d9_hlsl/include_shmap_filter_d3d9_hlsl.s3d_shadercode_run>
|
---|
16 |
|
---|
17 | ///////////////////////////////////////////////////////////////////////////////
|
---|
18 |
|
---|
19 | struct PS_INPUT
|
---|
20 | {
|
---|
21 | float2 mainTexCoord: TEXCOORD0;
|
---|
22 | float3 diffuse: TEXCOORD1;
|
---|
23 | float3 specular: TEXCOORD2;
|
---|
24 | #ifdef S3D_LIGHT_PROJ
|
---|
25 | float4 lightProjCoord: TEXCOORD3;
|
---|
26 | #endif
|
---|
27 | #ifdef S3D_LIGHT_SHMAP
|
---|
28 | float4 lightShmapCoord: TEXCOORD4;
|
---|
29 | #endif
|
---|
30 | };
|
---|
31 |
|
---|
32 | ///////////////////////////////////////////////////////////////////////////////
|
---|
33 |
|
---|
34 | sampler tex0: register(s0);
|
---|
35 | sampler tex1: register(s1);
|
---|
36 | #ifdef S3D_LIGHT_PROJ
|
---|
37 | sampler lightProjSamp: register(s2);
|
---|
38 | #endif
|
---|
39 | #ifdef S3D_LIGHT_SHMAP
|
---|
40 | sampler lightShmapSamp: register(s3);
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | ///////////////////////////////////////////////////////////////////////////////
|
---|
44 |
|
---|
45 | const float4 lightAmbient;
|
---|
46 | const float4 lightDiffuse;
|
---|
47 | const float4 lightSpecular;
|
---|
48 |
|
---|
49 | #ifdef S3D_LIGHT_SHMAP
|
---|
50 | const float4 lightShmapSize;
|
---|
51 | const float4 lightShmapRcpSize;
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | ///////////////////////////////////////////////////////////////////////////////
|
---|
55 |
|
---|
56 | #define S3D_INTENS_DISCARD_TRESHOLD 0.001
|
---|
57 | #define S3D_BRIGHT_EPS 0.01
|
---|
58 |
|
---|
59 | ///////////////////////////////////////////////////////////////////////////////
|
---|
60 | // Pixelshader
|
---|
61 | // Profile: 2x0
|
---|
62 |
|
---|
63 | float4 main(PS_INPUT input): COLOR0
|
---|
64 | {
|
---|
65 |
|
---|
66 | #ifdef S3D_LIGHT_SHMAP
|
---|
67 | // Shadow map:
|
---|
68 | float shmapVal = s3d_shmapFilter(
|
---|
69 | lightShmapSamp, input.lightShmapCoord,
|
---|
70 | lightShmapSize, lightShmapRcpSize);
|
---|
71 | #endif
|
---|
72 |
|
---|
73 |
|
---|
74 | float4 ocolor = float4(tex2D(tex0, input.mainTexCoord).xyzw);
|
---|
75 |
|
---|
76 | float4 outCol = float4(0.0,0.0,0.0,0.0);
|
---|
77 |
|
---|
78 | // Preserve original opacity from texture.
|
---|
79 | outCol.a = ocolor.a;
|
---|
80 |
|
---|
81 | outCol.rgb = ocolor.rgb * lightDiffuse.xyz + ocolor.rgb * lightSpecular.xyz;
|
---|
82 |
|
---|
83 | #ifdef S3D_LIGHT_SHMAP
|
---|
84 | shmapVal = shmapVal + 0.65;
|
---|
85 | shmapVal = clamp(shmapVal, 0.0, 1.0);
|
---|
86 | outCol *= shmapVal;
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | return outCol;
|
---|
90 | }
|
---|
91 |
|
---|
92 | ///////////////////////////////////////////////////////////////////////////////
|
---|