source: GTP/trunk/App/Demos/Illum/Shark3D/version164x12u/IllumDemo/bin/res/levelutil/shader/prog/d3d9_hlsl/comic_d3d9_hlsl_vs2x0.s3d_shadercode_run @ 2196

Revision 2196, 2.2 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
14#include \
15    <levelutil/shader/prog/d3d9_hlsl/include_stddef_d3d9_hlsl.s3d_shadercode_run>
16
17///////////////////////////////////////////////////////////////////////////////
18
19#ifndef S3D_LIGHT_CT
20#define S3D_LIGHT_CT 4
21#endif
22
23///////////////////////////////////////////////////////////////////////////////
24
25struct VS_INPUT
26{
27    float4 posObj: POSITION;
28    float3 normalObj: NORMAL;
29    float4 diffuse: COLOR0;
30};
31
32struct VS_OUTPUT
33{
34    float4 posScr: POSITION;
35    float2 mainTexCoord: TEXCOORD0;
36    float4 diffuse: COLOR0;
37    float fogCoord: TEXCOORD1;
38};
39
40///////////////////////////////////////////////////////////////////////////////
41
42const float4x4 projMat;
43const float4x4 matView;
44
45const float4 mtrlPower;
46const float4 mtrlEmissive;
47
48const s3d_StdProgLight lightArray[S3D_LIGHT_CT];
49const int activeLights;
50
51///////////////////////////////////////////////////////////////////////////////
52// Vertexshader
53// Profile: 2x0
54
55VS_OUTPUT main(VS_INPUT input)
56{
57    VS_OUTPUT output = (VS_OUTPUT)0;
58
59    float4 posView = mul(input.posObj, matView);
60    float3 normalView = normalize(mul(input.normalObj, matView).xyz);
61
62    output.posScr = mul(posView, projMat);
63    output.fogCoord = posView.z / posView.w;
64
65    float4 colDiffuse = mtrlEmissive;
66    float4 colSpecular = (float4)0;
67    for(int i = 0; i < activeLights; i++)
68    {
69        s3d_ColPair lightCol = s3d_calcPointLightTerm(
70                posView.xyz, normalView, mtrlPower.w, lightArray[i]);
71        colDiffuse += lightCol.diffuse;
72        colSpecular += lightCol.specular;
73    }
74
75    output.diffuse = input.diffuse;
76    output.mainTexCoord = dot(colDiffuse.xyz, float3(0.3, 0.5, 0.2));
77
78    return output;
79}
80
81///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.