source: GTP/trunk/App/Demos/Illum/IBRBillboardCloudTrees/Shark3D/bin/res/levelutil/shader/prog/d3d9_hlsl/direct_texturing_shmap_dirlight_d3d9_hlsl_ps2x0.s3d_shadercode_run @ 2517

Revision 2517, 2.4 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    // Shadow map:
68    float shmapVal = s3d_shmapFilter(
69            lightShmapSamp, input.lightShmapCoord,
70            lightShmapSize, lightShmapRcpSize);
71#endif
72   
73    float4 ocolor = float4(tex2D(tex0, input.mainTexCoord).xyzw);
74   
75    float4 outCol = float4(0.0,0.0,0.0,0.0);
76 
77    // Preserve original opacity from texture.
78    outCol.a = ocolor.a;
79
80    outCol.rgb = ocolor.rgb * lightDiffuse.xyz + ocolor.rgb * lightSpecular.xyz;
81
82#ifdef S3D_LIGHT_SHMAP
83    shmapVal = shmapVal + 0.65;
84    shmapVal = clamp(shmapVal, 0.0, 1.0);
85    outCol *= shmapVal;
86#endif
87
88    return outCol;
89}
90
91///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.