source: GTP/trunk/App/Demos/Illum/IBRBillboardCloudTrees/Shark3D/demo_v5x0x7_t164x31u_enterpr_kwin32/bin/res/levelutil/shader/prog/d3d9_hlsl/direct_texturing_shmap_spotlight_d3d9_hlsl_ps2x0.s3d_shadercode_run @ 2330

Revision 2330, 2.9 KB checked in by igarcia, 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
14#include \
15    <levelutil/shader/prog/d3d9_hlsl/include_shmap_filter_d3d9_hlsl.s3d_shadercode_run>
16
17///////////////////////////////////////////////////////////////////////////////
18
19struct 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
34sampler tex0: register(s0);
35sampler tex1: register(s1);
36#ifdef S3D_LIGHT_PROJ
37sampler lightProjSamp: register(s2);
38#endif
39#ifdef S3D_LIGHT_SHMAP
40sampler lightShmapSamp: register(s3);
41#endif
42
43///////////////////////////////////////////////////////////////////////////////
44
45const float4 lightAmbient;
46const float4 lightDiffuse;
47const float4 lightSpecular;
48
49#ifdef S3D_LIGHT_SHMAP
50const float4 lightShmapSize;
51const 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
63float4 main(PS_INPUT input): COLOR0
64{
65
66#ifdef S3D_LIGHT_SHMAP
67    float3 clipVal = input.lightShmapCoord.www
68            - abs(2 * input.lightShmapCoord.xyz - input.lightShmapCoord.www);
69    clip(clipVal.xyz);
70#endif
71
72#ifdef S3D_LIGHT_SHMAP
73    // Shadow map:
74    float shmapVal = s3d_shmapFilter(
75            lightShmapSamp, input.lightShmapCoord,
76            lightShmapSize, lightShmapRcpSize);
77    clip(shmapVal - S3D_INTENS_DISCARD_TRESHOLD);           
78#endif
79   
80    float4 ocolor = float4(tex2D(tex0, input.mainTexCoord).xyzw);
81   
82    float4 outCol = float4(0.0,0.0,0.0,0.0);
83 
84    // Preserve original opacity from texture.
85    outCol.a = ocolor.a;
86   
87    outCol.rgb = ocolor.rgb * lightDiffuse.xyz + ocolor.rgb * lightSpecular.xyz;
88
89#ifdef S3D_LIGHT_PROJ
90    float4 texColProjTex = tex2Dproj(lightProjSamp, input.lightProjCoord);
91    texColProjTex = clamp(texColProjTex, 0.5, 1.0);
92    outCol *= texColProjTex;
93#endif
94
95#ifdef S3D_LIGHT_SHMAP
96    shmapVal = shmapVal + 0.65;
97    shmapVal = clamp(shmapVal, 0.0, 1.0);
98    outCol *= shmapVal;
99#endif
100
101    return outCol;
102}
103
104///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.