source: GTP/trunk/App/Demos/Illum/IBRBillboardCloudTrees/Shark3D/demo_v5x0x7_t164x31u_enterpr_kwin32/src/res/levelutil/shader/prog/d3d9_hlsl/indirect_texturing_shmap_d3d9_hlsl_ps2x0.s3d_shadercode @ 2330

Revision 2330, 3.0 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    float2 texCoord0: TEXCOORD1;
23    float2 texCoord1: TEXCOORD2;
24    float3 diffuse: TEXCOORD3;
25    float3 specular: TEXCOORD4;   
26#ifdef S3D_LIGHT_PROJ
27    float4 lightProjCoord: TEXCOORD5;
28#endif
29#ifdef S3D_LIGHT_SHMAP
30    float4 lightShmapCoord: TEXCOORD6;
31#endif
32};
33
34///////////////////////////////////////////////////////////////////////////////
35
36sampler tex0: register(s0);
37sampler tex1: register(s1);
38#ifdef S3D_LIGHT_PROJ
39sampler lightProjSamp: register(s2);
40#endif
41#ifdef S3D_LIGHT_SHMAP
42sampler lightShmapSamp: register(s3);
43#endif
44
45///////////////////////////////////////////////////////////////////////////////
46
47const float4 lightAmbient;
48const float4 lightDiffuse;
49const float4 lightSpecular;
50
51#ifdef S3D_LIGHT_SHMAP
52const float4 lightShmapSize;
53const float4 lightShmapRcpSize;
54#endif
55
56///////////////////////////////////////////////////////////////////////////////
57
58#define S3D_INTENS_DISCARD_TRESHOLD 0.001
59#define S3D_BRIGHT_EPS 0.01
60
61///////////////////////////////////////////////////////////////////////////////
62// Pixelshader
63// Profile: 2x0
64
65float4 main(PS_INPUT input): COLOR0
66{
67
68#ifdef S3D_LIGHT_SHMAP
69    // Shadow map:
70    float shmapVal = s3d_shmapFilter(
71            lightShmapSamp, input.lightShmapCoord,
72            lightShmapSize, lightShmapRcpSize);
73#endif
74   
75    float sourceTextureSize = 16.0;
76    float sqrtNumSamples = 4.0;
77    float epsilonX = -0.35;
78    float epsilonY = -0.06;
79    float4 ocolor = float4(0.0, 1.0, 0.0, 0.0);
80    float2 epsilon = float2(epsilonX, epsilonY);
81    float4 value = tex2D(tex0, input.texCoord1).xyzw;
82    float2 coords = float2(0.0, 1.0) - abs(input.texCoord0 - ( value.xy - epsilon ) );
83    if (value.w != 0.0)
84    {   
85        float2 newcoord = (float2(1.0, 1.0) - value.zw) + ((coords * sourceTextureSize) / sqrtNumSamples);
86        ocolor = float4(tex2D(tex1, newcoord).xyzw);
87    }
88   
89    float4 outCol;
90    outCol.rgb = input.diffuse * ocolor.rgb * lightDiffuse.xyz * 3.0 + input.specular * ocolor.rgb * lightSpecular.xyz * 3.0 + ocolor.rgb;
91
92    // Preserve original opacity from texture.
93    outCol.a = ocolor.a;
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.